diff --git a/django/contrib/auth/middleware.py b/django/contrib/auth/middleware.py index cd4254b9b5..4075b856c0 100644 --- a/django/contrib/auth/middleware.py +++ b/django/contrib/auth/middleware.py @@ -25,6 +25,6 @@ class AuthenticationMiddleware: user_id = request.session[SESSION_KEY] request.user = UserWrapper(user_id) except KeyError: - from django.parts.auth.anonymoususers import AnonymousUser + from django.contrib.auth.models import AnonymousUser request.user = AnonymousUser() return None diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index da36e33922..64787e2d62 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -220,3 +220,48 @@ class Message(models.Model): def __repr__(self): return self.message + +class AnonymousUser: + id = None + + def __init__(self): + pass + + def __repr__(self): + return 'AnonymousUser' + + def save(self): + raise NotImplementedError + + def delete(self): + raise NotImplementedError + + def set_password(self, raw_password): + raise NotImplementedError + + def check_password(self, raw_password): + raise NotImplementedError + + def get_group_list(self): + return [] + + def set_groups(self, group_id_list): + raise NotImplementedError + + def get_permission_list(self): + return [] + + def set_permissions(self, permission_id_list): + raise NotImplementedError + + def has_perm(self, perm): + return False + + def has_module_perms(self, module): + return False + + def get_and_delete_messages(self): + return [] + + def is_anonymous(self): + return True diff --git a/django/parts/auth/anonymoususers.py b/django/parts/auth/anonymoususers.py deleted file mode 100644 index fea93e2f5a..0000000000 --- a/django/parts/auth/anonymoususers.py +++ /dev/null @@ -1,44 +0,0 @@ -class AnonymousUser: - id = None - - def __init__(self): - pass - - def __repr__(self): - return 'AnonymousUser' - - def save(self): - raise NotImplementedError - - def delete(self): - raise NotImplementedError - - def set_password(self, raw_password): - raise NotImplementedError - - def check_password(self, raw_password): - raise NotImplementedError - - def get_group_list(self): - return [] - - def set_groups(self, group_id_list): - raise NotImplementedError - - def get_permission_list(self): - return [] - - def set_permissions(self, permission_id_list): - raise NotImplementedError - - def has_perm(self, perm): - return False - - def has_module_perms(self, module): - return False - - def get_and_delete_messages(self): - return [] - - def is_anonymous(self): - return True diff --git a/docs/authentication.txt b/docs/authentication.txt index 81d1a4f52c..8dc7ccc431 100644 --- a/docs/authentication.txt +++ b/docs/authentication.txt @@ -192,7 +192,7 @@ the setting and checking of these values behind the scenes. Anonymous users --------------- -``django.parts.auth.anonymoususers.AnonymousUser`` is a class that implements +``django.contrib.auth.models.AnonymousUser`` is a class that implements the ``django.models.auth.users.User`` interface, with these differences: * ``id`` is always ``None``. diff --git a/docs/request_response.txt b/docs/request_response.txt index 13de013b6c..1566e6d3cf 100644 --- a/docs/request_response.txt +++ b/docs/request_response.txt @@ -88,7 +88,7 @@ All attributes except ``session`` should be considered read-only. ``user`` A ``django.models.auth.users.User`` object representing the currently logged-in user. If the user isn't currently logged in, ``user`` will be set - to an instance of ``django.parts.auth.anonymoususers.AnonymousUser``. You + to an instance of ``django.contrib.auth.models.AnonymousUser``. You can tell them apart with ``is_anonymous()``, like so:: if request.user.is_anonymous():