#NEWLINE# def authenticate_user( request ) : #NEWLINE# #INDENT# ( key , secret ) = get_basic_auth_data ( request ) #NEWLINE# if ( key and secret ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# user = authenticate ( access_key = key , secret_key = secret ) #NEWLINE# #UNINDENT# except ( DatabaseError , DataError ) : #NEWLINE# #INDENT# user = None #NEWLINE# #UNINDENT# if ( not user ) : #NEWLINE# #INDENT# user = authenticate ( username = key , password = secret ) #NEWLINE# #UNINDENT# return user