app/django/contrib/auth/middleware.py
author Lennard de Rijk <ljvderijk@gmail.com>
Tue, 24 Feb 2009 19:54:36 +0000
changeset 1487 d18c71f4fabe
parent 54 03e267d67478
permissions -rw-r--r--
Added list proposals redirect. This is used to list student proposals directed to one organization. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed

class LazyUser(object):
    def __get__(self, request, obj_type=None):
        if not hasattr(request, '_cached_user'):
            from django.contrib.auth import get_user
            request._cached_user = get_user(request)
        return request._cached_user

class AuthenticationMiddleware(object):
    def process_request(self, request):
        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'."
        request.__class__.user = LazyUser()
        return None