#NEWLINE# def login( self , **credentials ) : #NEWLINE# #INDENT# '\n        Sets the Factory to appear as if it has successfully logged into a site.\n\n        Returns True if login is possible; False if the provided credentials\n        are incorrect, or the user is inactive, or if the sessions framework is\n        not available.\n        ' #NEWLINE# user = authenticate ( ** cookie_data ) #NEWLINE# if ( user and user . is_active and ( 'django.contrib.sessions' in settings . INSTALLED_APPS ) ) : #NEWLINE# #INDENT# engine = import_module ( settings . SESSION_ENGINE ) #NEWLINE# request = HttpRequest ( ) #NEWLINE# if self . session : #NEWLINE# #INDENT# request . session = self . session #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# request . session = engine . SessionStore ( ) #NEWLINE# #UNINDENT# login ( request , user ) #NEWLINE# request . session . save ( ) #NEWLINE# session_cookie = settings . SESSION_COOKIE_NAME #NEWLINE# self . cookies [ session_cookie ] = request . session . session_key #NEWLINE# cookie_data = { #NEWLINE# #INDENT# 'max-age' : None , #NEWLINE# 'path' : '/' , #NEWLINE# 'domain' : settings . SESSION_COOKIE_DOMAIN , #NEWLINE# 'secure' : ( settings . SESSION_COOKIE_SECURE or None ) , #NEWLINE# 'expires' : None , #NEWLINE# #UNINDENT# } #NEWLINE# self . cookies [ session_cookie ] . update ( cookie_data ) #NEWLINE# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return False