Ticket #7599: get_user_permissions.patch
File get_user_permissions.patch, 1.1 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/backends.py
55 55 user_obj._group_perm_cache = set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()]) 56 56 return user_obj._group_perm_cache 57 57 58 def get_user_permissions(self, user_obj): 59 """ 60 Returns a set of permission strings directly tied to user_obj. 61 """ 62 return set([u"%s.%s" % (p.content_type.app_label, p.codename) 63 for p in user_obj.user_permissions.select_related()]) 64 58 65 def get_all_permissions(self, user_obj): 59 66 if not hasattr(user_obj, '_perm_cache'): 60 user_obj._perm_cache = se t([u"%s.%s" % (p.content_type.app_label, p.codename) for p in user_obj.user_permissions.select_related()])67 user_obj._perm_cache = self.get_user_permissions(user_obj) 61 68 user_obj._perm_cache.update(self.get_group_permissions(user_obj)) 62 69 return user_obj._perm_cache 63 70