Django

Code

root/django/branches/newforms-admin/django/contrib/auth/middleware.py

Revision 4265, 0.6 kB (checked in by adrian, 2 years ago)

Fixed #3191 -- Set 'svn:eol-style native' on the files that didn't have it. Thanks, jjl@pobox.com

  • Property svn:eol-style set to native
Line 
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
Note: See TracBrowser for help on using the browser.