Changeset - a38e328db172
[Not reviewed]
default
0 2 0
Søren Løvborg - 10 years ago 2015-07-14 13:59:59
kwi@kwi.dk
AuthUser: make get_perms method private

The get_perms method is used exactly once, by the permissions property.

A future, more thorough examination of the code may reveal if it should
stay or go; for now, just make it private. Also, enhance docstring
accuracy.
2 files changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/auth.py
Show inline comments
 
@@ -497,13 +497,13 @@ class AuthUser(object):
 

	
 
        self.propagate_data()
 
        self._instance = None
 

	
 
    @LazyProperty
 
    def permissions(self):
 
        return self.get_perms(user=self, cache=False)
 
        return self.__get_perms(user=self, cache=False)
 

	
 
    @property
 
    def api_keys(self):
 
        return self.get_api_keys()
 

	
 
    def propagate_data(self):
 
@@ -541,19 +541,19 @@ class AuthUser(object):
 

	
 
        if not self.username:
 
            self.username = 'None'
 

	
 
        log.debug('Auth User is now %s' % self)
 

	
 
    def get_perms(self, user, explicit=True, algo='higherwin', cache=False):
 
    def __get_perms(self, user, explicit=True, algo='higherwin', cache=False):
 
        """
 
        Fills user permission attribute with permissions taken from database
 
        works for permissions given for repositories, and for permissions that
 
        are granted to groups
 

	
 
        :param user: instance of User object from database
 
        :param user: `AuthUser` instance
 
        :param explicit: In case there are permissions both for user and a group
 
            that user is part of, explicit flag will define if user will
 
            explicitly override permissions from group, if it's False it will
 
            make decision based on the algo
 
        :param algo: algorithm to decide what permission should be choose if
 
            it's multiple defined, eg user in two different groups. It also
kallithea/lib/base.py
Show inline comments
 
@@ -179,13 +179,13 @@ class BaseVCSController(object):
 
    def _check_permission(self, action, user, repo_name, ip_addr=None):
 
        """
 
        Checks permissions using action (push/pull) user and repository
 
        name
 

	
 
        :param action: push or pull action
 
        :param user: user instance
 
        :param user: `User` instance
 
        :param repo_name: repository name
 
        """
 
        # check IP
 
        inherit = user.inherit_default_permissions
 
        ip_allowed = AuthUser.check_ip_allowed(user.user_id, ip_addr,
 
                                               inherit_from_default=inherit)
0 comments (0 inline, 0 general)