Anonymous avatar Anonymous committed 1b318f9

backend resolves user permissions

Comments (0)

Files changed (1)

djangotoolbox/contrib/auth/backends.py

     from sets import Set as set # Python 2.3 fallback
 
 from django.db import connection
-from djangotoolbox.contrib.auth.models import User, Permission, Group
+from django.contrib.auth.models import User, Permission, Group
 from django.contrib.contenttypes.models import ContentType
+from djangotoolbox.contrib.auth.models import PermissionList
 
 
 class ModelBackend(object):
         if user_obj.is_anonymous():
             return set()
         if not hasattr(user_obj, '_perm_cache'):
-            user_obj._perm_cache = set([u"%s.%s" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions])
-            user_obj._perm_cache.update(self.get_group_permissions(user_obj))
+            try:
+                pl = PermissionList.objects.get(user=user_obj)
+                user_obj._perm_cache = set([u"%s.%s" % (p.content_type.app_label, p.codename) for p in pl.permission_list])
+            except PermissionList.DoesNotExist:
+                user_obj._perm_cache = list()
+                pass
+            #user_obj._perm_cache.update(self.get_group_permissions(user_obj))
         return user_obj._perm_cache
 
     def has_perm(self, user_obj, perm):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.