Logo Search packages:      
Sourcecode: zope-groupuserfolder version File versions

def zope-groupuserfolder-3.1.1::GRUFUser::GRUFUserAtom::_getGroups (   self,
  no_recurse = 0,
  already_done = [],
  prefix = GROUP_PREFIX 
) [private]

getGroups(self, no_recurse = 0, already_done = [], prefix = GROUP_PREFIX) => list of strings

If this user is a user (uh, uh), get its groups.
THIS METHODS NOW SUPPORTS NESTED GROUPS ! :-)
The already_done parameter prevents infite recursions.
Keep it as it is, never give it a value.

If no_recurse is true, return only first level groups

This method is private and should remain so.

Definition at line 170 of file GRUFUser.py.

00170                                                                                   :
        """
        getGroups(self, no_recurse = 0, already_done = [], prefix = GROUP_PREFIX) => list of strings
        
        If this user is a user (uh, uh), get its groups.
        THIS METHODS NOW SUPPORTS NESTED GROUPS ! :-)
        The already_done parameter prevents infite recursions.
        Keep it as it is, never give it a value.

        If no_recurse is true, return only first level groups

        This method is private and should remain so.
        """
        # List this user's roles. We consider that roles starting 
        # with GROUP_PREFIX are in fact groups, and thus are 
        # returned (prefixed).
        if self._groups is not None:
            return self._groups

        # Populate cache if necessary
        if self._original_user_roles is None:
            self._original_user_roles = self.__underlying__.getRoles()

        # Scan roles to find groups
        ret = []
        for role in self._original_user_roles:
            # Inspect group-like roles
            if role.startswith(prefix):

                # Prevent infinite recursion
                if self._isGroup and role in already_done:
                    continue

                # Get the underlying group
                grp = self.aq_parent.getUser(role)
                if not grp:
                    continue    # Invalid group

                # Do not add twice the current group
                if role in ret:
                    continue

                # Append its nested groups (if recurse is asked)
                ret.append(role)
                if no_recurse:
                    continue
                for extend in grp.getGroups(already_done = ret):
                    if not extend in ret:
                        ret.append(extend)

        # Return the groups
        self._groups = tuple(ret)
        return self._groups


    security.declarePrivate('getGroupsWithoutPrefix')
    def getGroupsWithoutPrefix(self, **kw):


Generated by  Doxygen 1.6.0   Back to index