<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> from django . contrib import auth as django_auth <EOL> from django . contrib . auth import models as auth_models <EOL> from services . accounts import models as account_models <EOL> def authenticate_anonymous ( request ) : <EOL> if request . user . is_authenticated ( ) : <EOL> return account_models . UserProfile . objects . get ( <EOL> username = request . user . username <EOL> ) <EOL> else : <EOL> anonymous_u = account_models . UserProfile . objects . create_anonymous ( ) <EOL> django_auth . authenticate ( user = anonymous_u ) <EOL> django_auth . login ( request , anonymous_u ) <EOL> return anonymous_u <EOL> class AnonymousAuthenticationBackend ( object ) : <EOL> """<STR_LIT>""" <EOL> def authenticate ( self , user = None ) : <EOL> """<STR_LIT>""" <EOL> return user <EOL> def get_user ( self , user_id ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return auth_models . User . objects . get ( pk = user_id ) <EOL> except auth_models . User . DoesNotExist : <EOL> return None </s>
