mirror of
https://github.com/django/django.git
synced 2025-06-07 12:39:12 +00:00
magic-removal: moved django.parts.auth.anonymoususers.AnonymousUser to django.contrib.auth.models.AnonymousUser
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2494 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bc851653b7
commit
dc63d91c56
@ -25,6 +25,6 @@ class AuthenticationMiddleware:
|
|||||||
user_id = request.session[SESSION_KEY]
|
user_id = request.session[SESSION_KEY]
|
||||||
request.user = UserWrapper(user_id)
|
request.user = UserWrapper(user_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
from django.parts.auth.anonymoususers import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
request.user = AnonymousUser()
|
request.user = AnonymousUser()
|
||||||
return None
|
return None
|
||||||
|
@ -220,3 +220,48 @@ class Message(models.Model):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.message
|
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
|
||||||
|
@ -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
|
|
@ -192,7 +192,7 @@ the setting and checking of these values behind the scenes.
|
|||||||
Anonymous users
|
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:
|
the ``django.models.auth.users.User`` interface, with these differences:
|
||||||
|
|
||||||
* ``id`` is always ``None``.
|
* ``id`` is always ``None``.
|
||||||
|
@ -88,7 +88,7 @@ All attributes except ``session`` should be considered read-only.
|
|||||||
``user``
|
``user``
|
||||||
A ``django.models.auth.users.User`` object representing the currently
|
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
|
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::
|
can tell them apart with ``is_anonymous()``, like so::
|
||||||
|
|
||||||
if request.user.is_anonymous():
|
if request.user.is_anonymous():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user