diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py index 852057bf53..6e0b8e0d97 100644 --- a/django/contrib/admin/views/decorators.py +++ b/django/contrib/admin/views/decorators.py @@ -1,6 +1,6 @@ from django.core.extensions import DjangoContext, render_to_response from django.conf.settings import SECRET_KEY -from django.models.auth import users +from django.models.auth import User, SESSION_KEY from django.utils import httpwrappers import base64, md5 import cPickle as pickle @@ -66,14 +66,14 @@ def staff_member_required(view_func): # Check the password. username = request.POST.get('username', '') try: - user = users.get_object(username__exact=username, is_staff__exact=True) - except users.UserDoesNotExist: + user = User.objects.get_object(username__exact=username, is_staff__exact=True) + except User.DoesNotExist: message = ERROR_MESSAGE if '@' in username: # Mistakenly entered e-mail address instead of username? Look it up. try: - user = users.get_object(email__exact=username) - except users.UserDoesNotExist: + user = User.objects.get_object(email__exact=username) + except User.DoesNotExist: message = _("Usernames cannot contain the '@' character.") else: message = _("Your e-mail address is not your username. Try '%s' instead.") % user.username @@ -82,7 +82,7 @@ def staff_member_required(view_func): # The user data is correct; log in the user in and continue. else: if user.check_password(request.POST.get('password', '')): - request.session[users.SESSION_KEY] = user.id + request.session[SESSION_KEY] = user.id if request.POST.has_key('post_data'): post_data = _decode_post_data(request.POST['post_data']) if post_data and not post_data.has_key(LOGIN_FORM_KEY): diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py index 5918db7dc8..af114dc136 100644 --- a/django/contrib/comments/views/comments.py +++ b/django/contrib/comments/views/comments.py @@ -2,7 +2,7 @@ from django.core import formfields, validators from django.core.mail import mail_admins, mail_managers from django.core.exceptions import Http404, ObjectDoesNotExist from django.core.extensions import DjangoContext, render_to_response -from django.models.auth import users +from django.models.auth import SESSION_KEY from django.models.comments import comments, freecomments from django.models.core import contenttypes from django.parts.auth.formfields import AuthenticationForm @@ -216,7 +216,7 @@ def post_comment(request): # If user gave correct username/password and wasn't already logged in, log them in # so they don't have to enter a username/password again. if manipulator.get_user() and new_data.has_key('password') and manipulator.get_user().check_password(new_data['password']): - request.session[users.SESSION_KEY] = manipulator.get_user_id() + request.session[SESSION_KEY] = manipulator.get_user_id() if errors or request.POST.has_key('preview'): class CommentFormWrapper(formfields.FormWrapper): def __init__(self, manipulator, new_data, errors, rating_choices): diff --git a/django/contrib/syndication/feeds.py b/django/contrib/syndication/feeds.py index 49b34858dc..2a08cae109 100644 --- a/django/contrib/syndication/feeds.py +++ b/django/contrib/syndication/feeds.py @@ -1,6 +1,6 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist from django.core.template import Context, loader, Template, TemplateDoesNotExist -from django.models.core import sites +from django.models.core import Site from django.utils import feedgenerator from django.conf.settings import LANGUAGE_CODE, SETTINGS_MODULE @@ -52,7 +52,7 @@ class Feed: else: obj = None - current_site = sites.get_current() + current_site = Site.objects.get_current() link = self.__get_dynamic_attr('link', obj) link = add_domain(current_site.domain, link) diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index 48e20d2fb2..1520bd3be2 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -97,13 +97,13 @@ class ModPythonRequest(httpwrappers.HttpRequest): def _get_user(self): if not hasattr(self, '_user'): - from django.models.auth import users + from django.models.auth import User, SESSION_KEY try: - user_id = self.session[users.SESSION_KEY] + user_id = self.session[SESSION_KEY] if not user_id: raise ValueError - self._user = users.get_object(pk=user_id) - except (AttributeError, KeyError, ValueError, users.UserDoesNotExist): + self._user = User.objects.get_object(pk=user_id) + except (AttributeError, KeyError, ValueError, user.DoesNotExist): from django.parts.auth import anonymoususers self._user = anonymoususers.AnonymousUser() return self._user diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index 84e9ac2d14..c9d5011c3f 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -118,13 +118,13 @@ class WSGIRequest(httpwrappers.HttpRequest): def _get_user(self): if not hasattr(self, '_user'): - from django.models.auth import users + from django.models.auth import User, SESSION_KEY try: - user_id = self.session[users.SESSION_KEY] + user_id = self.session[SESSION_KEY] if not user_id: raise ValueError - self._user = users.get_object(pk=user_id) - except (AttributeError, KeyError, ValueError, users.UserDoesNotExist): + self._user = User.objects.get_object(pk=user_id) + except (AttributeError, KeyError, ValueError, user.DoesNotExist): from django.parts.auth import anonymoususers self._user = anonymoususers.AnonymousUser() return self._user diff --git a/django/models/auth.py b/django/models/auth.py index 381061d0cb..3dcdd75905 100644 --- a/django/models/auth.py +++ b/django/models/auth.py @@ -3,6 +3,8 @@ from django.db import models from django.models import core from django.utils.translation import gettext_lazy as _ +SESSION_KEY = '_auth_user_id' + class Permission(models.Model): name = models.CharField(_('name'), maxlength=50) package = models.ForeignKey(core.Package, db_column='package') @@ -47,9 +49,6 @@ class User(models.Model): class META: verbose_name = _('User') verbose_name_plural = _('Users') - module_constants = { - 'SESSION_KEY': '_auth_user_id', - } ordering = ('username',) exceptions = ('SiteProfileNotAvailable',) admin = models.Admin(