app/django/contrib/auth/middleware.py
changeset 54 03e267d67478
equal deleted inserted replaced
53:57b4279d8c4e 54:03e267d67478
       
     1 class LazyUser(object):
       
     2     def __get__(self, request, obj_type=None):
       
     3         if not hasattr(request, '_cached_user'):
       
     4             from django.contrib.auth import get_user
       
     5             request._cached_user = get_user(request)
       
     6         return request._cached_user
       
     7 
       
     8 class AuthenticationMiddleware(object):
       
     9     def process_request(self, request):
       
    10         assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
       
    11         request.__class__.user = LazyUser()
       
    12         return None