Skip to content

Commit 3c57822

Browse files
Fixed #2702 -- Fixed LazyUser to store cache as attribute of request, not class. Thanks for the patch, jkocherhans
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3754 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 086992c commit 3c57822

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Diff for: django/contrib/auth/middleware.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
class LazyUser(object):
2-
def __init__(self):
3-
self._user = None
4-
52
def __get__(self, request, obj_type=None):
6-
if self._user is None:
3+
if not hasattr(request, '_cached_user'):
74
from django.contrib.auth import get_user
8-
self._user = get_user(request)
9-
return self._user
5+
request._cached_user = get_user(request)
6+
return request._cached_user
107

118
class AuthenticationMiddleware(object):
129
def process_request(self, request):

0 commit comments

Comments
 (0)