Ticket #15299: 15299.2.diff
File 15299.2.diff, 4.7 KB (added by , 14 years ago) |
---|
-
docs/topics/auth.txt
1334 1334 1335 1335 The currently logged-in user's permissions are stored in the template variable 1336 1336 ``{{ perms }}``. This is an instance of 1337 :class:`django.co re.context_processors.PermWrapper`, which is a1337 :class:`django.contrib.auth.context_processors.PermWrapper`, which is a 1338 1338 template-friendly proxy of permissions. 1339 1339 1340 1340 In the ``{{ perms }}`` object, single-attribute lookup is a proxy to -
docs/ref/templates/api.txt
423 423 via the :doc:`messages framework </ref/contrib/messages>`. 424 424 425 425 * ``perms`` -- An instance of 426 ``django.co re.context_processors.PermWrapper``, representing the426 ``django.contrib.auth.context_processors.PermWrapper``, representing the 427 427 permissions that the currently logged-in user has. 428 428 429 .. versionchanged:: 1.3 430 ``perms`` was moved in this release from 431 ``django.core.context_processors.auth`` to its current location. 432 429 433 .. versionchanged:: 1.2 430 434 This context processor was moved in this release from 431 435 ``django.core.context_processors.auth`` to its current location. -
django/core/context_processors.py
86 86 # PermWrapper and PermLookupDict proxy the permissions system into objects that 87 87 # the template system can understand. 88 88 89 # Deprecation Warning: PermWrapper would be accessible from django.contrib.auth.context_processors from version 1.3 90 # and it would be removed from django.core.context_processors in future versions. 91 89 92 class PermLookupDict(object): 90 93 def __init__(self, user, module_name): 91 94 self.user, self.module_name = user, module_name … … 99 102 def __nonzero__(self): 100 103 return self.user.has_module_perms(self.module_name) 101 104 105 102 106 class PermWrapper(object): 103 107 def __init__(self, user): 108 import warnings 109 warnings.warn( 110 'PermWrapper would be accessible from django.contrib.auth.context_processors 111 from version 1.3 and it would be removed from django.core.context_processors in future versions.', 112 DeprecationWarning 113 ) 104 114 self.user = user 105 115 106 116 def __getitem__(self, module_name): -
django/contrib/auth/context_processors.py
1 from django.core.context_processors import PermWrapper2 1 from django.utils.functional import lazy, memoize, SimpleLazyObject 3 2 from django.contrib import messages 4 3 4 # PermWrapper and PermLookupDict proxy the permissions system into objects that 5 # the template system can understand. 6 7 class PermLookupDict(object): 8 def __init__(self, user, module_name): 9 self.user, self.module_name = user, module_name 10 11 def __repr__(self): 12 return str(self.user.get_all_permissions()) 13 14 def __getitem__(self, perm_name): 15 return self.user.has_perm("%s.%s" % (self.module_name, perm_name)) 16 17 def __nonzero__(self): 18 return self.user.has_module_perms(self.module_name) 19 20 21 class PermWrapper(object): 22 def __init__(self, user): 23 self.user = user 24 25 def __getitem__(self, module_name): 26 return PermLookupDict(self.user, module_name) 27 28 def __iter__(self): 29 # I am large, I contain multitudes. 30 raise TypeError("PermWrapper is not iterable.") 31 5 32 def auth(request): 6 33 """ 7 34 Returns context variables required by apps that use Django's authentication -
docs/internals/deprecation.txt
18 18 * The :mod:`django.contrib.gis.db.backend` module, including the 19 19 ``SpatialBackend`` interface, is deprecated since the 1.2 release. 20 20 21 * In this release :class:`django.core.context_processors.PermWrapper` will be 22 moved to :class:`django.contrib.auth.context_processors.PermWrapper`. The 23 former location is deprecated from 1.3 and would be removed in future releases. 24 21 25 * 1.4 22 26 * ``CsrfResponseMiddleware``. This has been deprecated since the 1.2 23 27 release, in favour of the template tag method for inserting the CSRF