Django

Code

Changeset 7822

Show
Ignore:
Timestamp:
07/02/08 00:00:09 (2 months ago)
Author:
gwilson
Message:

Added docstring and other minor style fixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/auth/backends.py

    r7201 r7822  
     1try: 
     2    set 
     3except NameError: 
     4    from sets import Set as set # Python 2.3 fallback 
     5 
    16from django.db import connection 
    27from django.contrib.auth.models import User 
    38 
    4 try:  
    5     set  
    6 except NameError:  
    7     from sets import Set as set # Python 2.3 fallback 
    8          
     9 
    910class ModelBackend(object): 
    1011    """ 
    11     Authenticate against django.contrib.auth.models.User 
     12    Authenticates against django.contrib.auth.models.User. 
    1213    """ 
    1314    # TODO: Model, login attribute name and password attribute name should be 
     
    2223 
    2324    def get_group_permissions(self, user_obj): 
    24         "Returns a list of permission strings that this user has through his/her groups." 
     25        """ 
     26        Returns a set of permission strings that this user has through his/her 
     27        groups. 
     28        """ 
    2529        if not hasattr(user_obj, '_group_perm_cache'): 
    2630            cursor = connection.cursor() 
     
    5155            user_obj._group_perm_cache = set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()]) 
    5256        return user_obj._group_perm_cache 
    53      
     57 
    5458    def get_all_permissions(self, user_obj): 
    5559        if not hasattr(user_obj, '_perm_cache'): 
     
    6266 
    6367    def has_module_perms(self, user_obj, app_label): 
     68        """ 
     69        Returns True if user_obj has any permissions in the given app_label. 
     70        """ 
    6471        return bool(len([p for p in self.get_all_permissions(user_obj) if p[:p.index('.')] == app_label])) 
    6572