#NEWLINE# @ classmethod #NEWLINE# def _password_match( self , attr , password , _type = 'paste' ) : #NEWLINE# #INDENT# "\n        Checks if $password is the correct password for $attr.\n\n        $attr should be a paste_id or username\n        $_type should be set to 'user' or 'paste' respectively\n        $password should be plaintext.\n\n        " #NEWLINE# if ( _type == 'paste' ) : #NEWLINE# #INDENT# thing = self . by_hash ( attr ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( _type == 'user' ) : #NEWLINE# #INDENT# thing = self . by_username ( attr ) #NEWLINE# #UNINDENT# #UNINDENT# if ( thing is None ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# current = thing [ 'password' ] #NEWLINE# if ( not ( self . _hash_password ( password , current ) == current ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return True