Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

magic-removal: fixed #1410. The UserSource class will eventually be r…

…eplaced with the muti-auth stuff.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2431 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 36bfffccc482a6ffcd78b171df7b8d77debefe8a 1 parent 64330d7
@jkocherhans jkocherhans authored
View
11 django/contrib/auth/middleware.py
@@ -1,5 +1,6 @@
-class RequestUserMiddleware:
- def process_request(self, request):
+# TODO: this will be replaced by the muti-auth stuff
+class UserSource:
+ def get_user(self, request):
from django.contrib.auth.models import User, SESSION_KEY
try:
user_id = request.session[SESSION_KEY]
@@ -9,5 +10,9 @@ def process_request(self, request):
except (AttributeError, KeyError, ValueError, User.DoesNotExist):
from django.parts.auth import anonymoususers
user = anonymoususers.AnonymousUser()
- request.user = user
+ return user
+
+class RequestUserMiddleware:
+ def process_request(self, request):
+ request._user_source = UserSource()
return None
View
9 django/core/handlers/modpython.py
@@ -98,6 +98,14 @@ def _get_raw_post_data(self):
self._raw_post_data = self._req.read()
return self._raw_post_data
+ def _get_user(self):
+ if not hasattr(self, '_user'):
+ self._user = self._user_source.get_user(self)
+ return self._user
+
+ def _set_user(self, value):
+ self._user = value
+
GET = property(_get_get, _set_get)
POST = property(_get_post, _set_post)
COOKIES = property(_get_cookies, _set_cookies)
@@ -105,6 +113,7 @@ def _get_raw_post_data(self):
META = property(_get_meta)
REQUEST = property(_get_request)
raw_post_data = property(_get_raw_post_data)
+ user = property(_get_user, _set_user)
class ModPythonHandler(BaseHandler):
def __call__(self, req):
View
9 django/core/handlers/wsgi.py
@@ -119,12 +119,21 @@ def _get_raw_post_data(self):
self._raw_post_data = self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"]))
return self._raw_post_data
+ def _get_user(self):
+ if not hasattr(self, '_user'):
+ self._user = self._user_source.get_user(self)
+ return self._user
+
+ def _set_user(self, value):
+ self._user = value
+
GET = property(_get_get, _set_get)
POST = property(_get_post, _set_post)
COOKIES = property(_get_cookies, _set_cookies)
FILES = property(_get_files)
REQUEST = property(_get_request)
raw_post_data = property(_get_raw_post_data)
+ user = property(_get_user, _set_user)
class WSGIHandler(BaseHandler):
def __call__(self, environ, start_response):
Please sign in to comment.
Something went wrong with that request. Please try again.