diff -r e752cdf831a7 django/contrib/auth/middleware.py
a
|
b
|
|
13 | 13 | class AuthenticationMiddleware(object): |
14 | 14 | def process_request(self, request): |
15 | 15 | 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'." |
16 | | request.__class__.user = LazyUser() |
| 16 | |
| 17 | # We dynamically subclass request.__class__ rather than monkey patch the |
| 18 | # original class. |
| 19 | class RequestWithUser(request.__class__): |
| 20 | user = LazyUser() |
| 21 | |
| 22 | request.__class__ = RequestWithUser |
17 | 23 | return None |
18 | 24 | |
19 | 25 | |