Ticket #3032: anonymous-user-properties.2.diff
File anonymous-user-properties.2.diff, 3.0 KB (added by , 17 years ago) |
---|
-
django/db/models/manager.py
111 111 if instance != None: 112 112 raise AttributeError, "Manager isn't accessible via %s instances" % type.__name__ 113 113 return self.manager 114 115 class EmptyManager(Manager): 116 def get_query_set(self): 117 return self.get_empty_query_set() -
django/contrib/auth/tests.py
1 1 """ 2 >>> from models import User 2 >>> from models import User, AnonymousUser 3 3 >>> u = User.objects.create_user('testuser', 'test@example.com', 'testpw') 4 4 >>> u.has_usable_password() 5 5 True … … 16 16 >>> u2 = User.objects.create_user('testuser2', 'test2@example.com') 17 17 >>> u2.has_usable_password() 18 18 False 19 >>> a = AnonymousUser() 20 >>> a.is_staff 21 False 22 >>> a.groups.all() 23 [] 24 >>> a.user_permissions.all() 25 [] 19 26 """ 27 No newline at end of file -
django/contrib/auth/models.py
1 1 from django.core import validators 2 2 from django.core.exceptions import ImproperlyConfigured 3 3 from django.db import connection, models 4 from django.db.models.manager import EmptyManager 4 5 from django.contrib.contenttypes.models import ContentType 5 6 from django.utils.encoding import smart_str 6 7 from django.utils.translation import ugettext_lazy as _ … … 293 294 class AnonymousUser(object): 294 295 id = None 295 296 username = '' 297 is_staff = False 298 is_active = True 299 is_superuser = False 300 _groups = EmptyManager() 301 _user_permissions = EmptyManager() 296 302 297 303 def __init__(self): 298 304 pass … … 325 331 raise NotImplementedError 326 332 327 333 def _get_groups(self): 328 r aise NotImplementedError334 return self._groups 329 335 groups = property(_get_groups) 330 336 331 337 def _get_user_permissions(self): 332 r aise NotImplementedError338 return self._user_permissions 333 339 user_permissions = property(_get_user_permissions) 334 340 335 341 def has_perm(self, perm): -
docs/authentication.txt
244 244 the ``django.contrib.auth.models.User`` interface, with these differences: 245 245 246 246 * ``id`` is always ``None``. 247 * ``is_staff`` and ``is_superuser`` are always False 248 * ``is_active`` is always True 249 * ``groups`` and ``user_permissions`` are always empty 247 250 * ``is_anonymous()`` returns ``True`` instead of ``False``. 248 251 * ``is_authenticated()`` returns ``False`` instead of ``True``. 249 252 * ``has_perm()`` always returns ``False``.