Ticket #7599: get_user_permissions.patch

File get_user_permissions.patch, 1.1 KB (added by Gary Wilson, 16 years ago)
  • django/contrib/auth/backends.py

     
    5555            user_obj._group_perm_cache = set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()])
    5656        return user_obj._group_perm_cache
    5757
     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
    5865    def get_all_permissions(self, user_obj):
    5966        if not hasattr(user_obj, '_perm_cache'):
    60             user_obj._perm_cache = set([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)
    6168            user_obj._perm_cache.update(self.get_group_permissions(user_obj))
    6269        return user_obj._perm_cache
    6370
Back to Top