#NEWLINE# def requires_basic_auth( func ) : #NEWLINE# #INDENT# "Specific (basic) authentication decorator.\n\n    This is used to note which object methods require username/password\n    authorization and won't work with token based authorization.\n\n    " #NEWLINE# @ wraps ( func ) #NEWLINE# def auth_wrapper( self , * args , **kwargs ) : #NEWLINE# #INDENT# if ( hasattr ( self , 'session' ) and self . session . auth ) : #NEWLINE# #INDENT# return func ( self , * args , ** kwargs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# from . exceptions import error_for #NEWLINE# r = generate_fake_error_response ( '{"message": "Requires username/password authentication"}' ) #NEWLINE# raise error_for ( r ) #NEWLINE# #UNINDENT# #UNINDENT# return auth_wrapper