Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Static Private Attributes
GroupUserFolder.GRUFUser.GRUFGroup Class Reference
Inheritance diagram for GroupUserFolder.GRUFUser.GRUFGroup:
Inheritance graph
[legend]
Collaboration diagram for GroupUserFolder.GRUFUser.GRUFGroup:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def getRealId
def getMemberIds
def getUserMemberIds
def getGroupMemberIds
def hasMember
def addMember
def removeMember
def setMembers
def clearCachedGroupsAndRoles
def isGroup
def getUserSourceId
def getGroupNames
def getGroupIds
def getAllGroups
def getAllGroupNames
def getAllGroupIds
def getGroups
def getImmediateGroups
def getGroupsWithoutPrefix
def getUserNameWithoutGroupPrefix
def getUserId
def getName
def getUserName
def getId
def getRoles
def getUserRoles
def getGroupRoles
def getRolesInContext
def getDomains
def getProperty
def hasProperty
def setProperty
def authenticate
def allowed
def hasRole
def __getattr__
def getUnwrappedUser
def __getitem__
def asHTML
def isInGroup

Public Attributes

 id

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _getLDAPMemberIds
def _getMemberIds

Static Private Attributes

tuple __implements__ = (IGroup, )

Detailed Description

This is the class for actual group objects

Definition at line 760 of file GRUFUser.py.


Member Function Documentation

def GroupUserFolder.GRUFUser.GRUFUserAtom.__getattr__ (   self,
  name 
) [inherited]

Definition at line 586 of file GRUFUser.py.

00586 
00587     def __getattr__(self, name):
00588         # This will call the underlying object's methods
00589         # if they are not found in this user object.
00590         # We will have to check Chris' http://www.plope.com/Members/chrism/plone_on_zope_head
00591         # to make it work with Zope HEAD.
00592         ret = getattr(self.__dict__['__underlying__'], name)
00593         return ret

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.__getitem__ (   self,
  name 
) [inherited]

Definition at line 601 of file GRUFUser.py.

00601 
00602     def __getitem__(self, name):
00603         # This will call the underlying object's methods
00604         # if they are not found in this user object.
00605         return self.__underlying__[name]

Here is the caller graph for this function:

_getLDAPMemberIds(self,) => Uses LDAPUserFolder to find
users in a group.

Definition at line 774 of file GRUFUser.py.

00774 
00775     def _getLDAPMemberIds(self,):
00776         """
00777         _getLDAPMemberIds(self,) => Uses LDAPUserFolder to find
00778         users in a group.
00779         """
00780         # Find the right source
00781         gruf = self.aq_parent
00782         src = None
00783         for src in gruf.listUserSources():
00784             if not src.meta_type == "LDAPUserFolder":
00785                 continue
00786         if src is None:
00787             Log(LOG_DEBUG, "No LDAPUserFolder source found")
00788             return []
00789 
00790         # Find the group in LDAP
00791         groups = src.getGroups()
00792         groupid = self.getId()
00793         grp = [ group for group in groups if group[0] == self.getId() ]
00794         if not grp:
00795             Log(LOG_DEBUG, "No such group ('%s') found." % (groupid,))
00796             return []
00797 
00798         # Return the grup member ids
00799         userids = src.getGroupedUsers(grp)
00800         Log(LOG_DEBUG, "We've found %d users belonging to the group '%s'" % (len(userids), grp), )
00801         return userids
    
def GroupUserFolder.GRUFUser.GRUFGroup._getMemberIds (   self,
  users = 1,
  groups = 1,
  transitive = 1 
) [private]
Return the member ids (users and groups) of the atoms of this group.
Transitiveness attribute is ignored with LDAP (no nested groups with
LDAP anyway).
This method now uses a shortcut to fetch members of an LDAP group
(stored either within Zope or within your LDAP server)

Definition at line 802 of file GRUFUser.py.

00802 
00803     def _getMemberIds(self, users = 1, groups = 1, transitive = 1, ):
00804         """
00805         Return the member ids (users and groups) of the atoms of this group.
00806         Transitiveness attribute is ignored with LDAP (no nested groups with
00807         LDAP anyway).
00808         This method now uses a shortcut to fetch members of an LDAP group
00809         (stored either within Zope or within your LDAP server)
00810         """
00811         # Initial parameters.
00812         # We fetch the users/groups list depending on what we search,
00813         # and carefuly avoiding to use LDAP sources.
00814         gruf = self.aq_parent
00815         ldap_sources = []
00816         lst = []
00817         if transitive:
00818             method = "getAllGroupIds"
00819         else:
00820             method = "getGroupIds"
00821         if users:
00822             for src in gruf.listUserSources():
00823                 if src.meta_type == 'LDAPUserFolder':
00824                     ldap_sources.append(src)
00825                     continue # We'll fetch 'em later
00826                 lst.extend(src.getUserNames())
00827         if groups:
00828             lst.extend(gruf.getGroupIds())
00829 
00830         # First extraction for regular user sources.
00831         # This part is very very long, and the more users you have,
00832         # the longer this method will be.
00833         groupid = self.getId()
00834         groups_mapping = {}
00835         for u in lst:
00836             usr = gruf.getUser(u)
00837             if not usr:
00838                 groups_mapping[u] = []
00839                 Log(LOG_WARNING, "Invalid user retreiving:", u)
00840             else:
00841                 groups_mapping[u] = getattr(usr, method)()
00842         members = [u for u in lst if groupid in groups_mapping[u]]
00843 
00844         # If we have LDAP sources, we fetch user-group mapping inside directly
00845         groupid = self.getId()
00846         for src in ldap_sources:
00847             groups = src.getGroups()
00848             # With LDAPUserFolder >= 2.7 we need to add GROUP_PREFIX to group_name
00849             # We keep backward compatibility
00850             grp = [ group for group in groups if group[0] == self.getId() or \
00851                                                  GROUP_PREFIX + group[0] == self.getId()]
00852             if not grp:
00853                 Log(LOG_DEBUG, "No such group ('%s') found." % (groupid,))
00854                 continue
00855 
00856             # Return the grup member ids
00857             userids = [ str(u) for u in src.getGroupedUsers(grp) ]
00858             Log(LOG_DEBUG, "We've found %d users belonging to the group '%s'" % (len(userids), grp), )
00859             members.extend(userids)
00860 
00861         # Return the members we've found
00862         return members

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFGroup.addMember (   self,
  userid 
)
Add a user the the current group

Definition at line 886 of file GRUFUser.py.

00886 
00887     def addMember(self, userid):
00888         """Add a user the the current group"""
00889         gruf = self.aq_parent
00890         groupid = self.getId()
00891         usr = gruf.getUser(userid)
00892         if not usr:
00893             raise ValueError, "Invalid user: '%s'" % (userid, )
00894         if not groupid in gruf.getGroupNames() + gruf.getGroupIds():
00895             raise ValueError, "Invalid group: '%s'" % (groupid, )
00896         groups = list(usr.getGroups())
00897         groups.append(groupid)
00898         groups = GroupUserFolder.unique(groups)
00899         return gruf._updateUser(userid, groups = groups)

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.allowed (   self,
  object,
  object_roles = None 
) [inherited]
Check whether the user has access to object. The user must
   have one of the roles in object_roles to allow access.

Definition at line 478 of file GRUFUser.py.

00478 
00479     def allowed(self, object, object_roles=None):
00480         """Check whether the user has access to object. The user must
00481            have one of the roles in object_roles to allow access."""
00482 
00483         if object_roles is _what_not_even_god_should_do:
00484             return 0
00485 
00486         # Short-circuit the common case of anonymous access.
00487         if object_roles is None or 'Anonymous' in object_roles:
00488             return 1
00489 
00490         # Provide short-cut access if object is protected by 'Authenticated'
00491         # role and user is not nobody
00492         if 'Authenticated' in object_roles and \
00493             (self.getUserName() != 'Anonymous User'):
00494             return 1
00495 
00496         # Check for ancient role data up front, convert if found.
00497         # This should almost never happen, and should probably be
00498         # deprecated at some point.
00499         if 'Shared' in object_roles:
00500             object_roles = self._shared_roles(object)
00501             if object_roles is None or 'Anonymous' in object_roles:
00502                 return 1
00503 
00504 
00505         # Trying to make some speed improvements, changes starts here.
00506         # Helge Tesdal, Plone Solutions AS, http://www.plonesolutions.com
00507         # We avoid using the getRoles() and getRolesInContext() methods to be able
00508         # to short circuit.
00509 
00510         # Dict for faster lookup and avoiding duplicates
00511         object_roles_dict = {}
00512         for role in object_roles:
00513             object_roles_dict[role] = 1
00514 
00515         if [role for role in self.getUserRoles() if object_roles_dict.has_key(role)]:
00516             if self._check_context(object):
00517                 return 1
00518             return None
00519 
00520         # Try the top level group roles.
00521         if [role for role in self.getGroupRoles() if object_roles_dict.has_key(role)]:
00522             if self._check_context(object):
00523                 return 1
00524             return None
00525 
00526         user_groups = self.getGroups()
00527         # No luck on the top level, try local roles
00528         inner_obj = getattr(object, 'aq_inner', object)
00529         userid = self.getId()
00530         while 1:
00531             local_roles = getattr(inner_obj, '__ac_local_roles__', None)
00532             if local_roles:
00533                 if callable(local_roles):
00534                     local_roles = local_roles()
00535                 dict = local_roles or {}
00536 
00537                 if [role for role in dict.get(userid, []) if object_roles_dict.has_key(role)]:
00538                     if self._check_context(object):
00539                         return 1
00540                     return None
00541 
00542                 # Get roles & local roles for groups
00543                 # This handles nested groups as well
00544                 for groupid in user_groups:
00545                     if [role for role in dict.get(groupid, []) if object_roles_dict.has_key(role)]:
00546                         if self._check_context(object):
00547                             return 1
00548                         return None
00549 
00550             # LocalRole blocking
00551             obj = getattr(inner_obj, 'aq_base', inner_obj)
00552             if getattr(obj, '__ac_local_roles_block__', None):
00553                 break
00554 
00555             # Loop control
00556             inner = getattr(inner_obj, 'aq_inner', inner_obj)
00557             parent = getattr(inner, 'aq_parent', None)
00558             if parent is not None:
00559                 inner_obj = parent
00560                 continue
00561             if hasattr(inner_obj, 'im_self'):
00562                 inner_obj=inner_obj.im_self
00563                 inner_obj=getattr(inner_obj, 'aq_inner', inner_obj)
00564                 continue
00565             break
00566         return None
00567 

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.asHTML (   self,
  implicit = 0 
) [inherited]
asHTML(self, implicit=0) => HTML string
Used to generate homogeneous links for management screens

Definition at line 610 of file GRUFUser.py.

00610 
00611     def asHTML(self, implicit=0):
00612         """
00613         asHTML(self, implicit=0) => HTML string
00614         Used to generate homogeneous links for management screens
00615         """
00616         acl_users = self.acl_users
00617         if self.isGroup():
00618             color = acl_users.group_color
00619             kind = "Group"
00620         else:
00621             color = acl_users.user_color
00622             kind = "User"
00623 
00624         ret = '''<a href="%(href)s" alt="%(alt)s"><font color="%(color)s">%(name)s</font></a>''' % {
00625             "color": color,
00626             "href": "%s/%s/manage_workspace?FORCE_USER=1" % (acl_users.absolute_url(), self.getId(), ),
00627             "name": self.getUserNameWithoutGroupPrefix(),
00628             "alt": "%s (%s)" % (self.getUserNameWithoutGroupPrefix(), kind, ),
00629             }
00630         if implicit:
00631             return "<i>%s</i>" % ret
00632         return ret
00633 
    
def GroupUserFolder.GRUFUser.GRUFUserAtom.authenticate (   self,
  password,
  request 
) [inherited]

Definition at line 470 of file GRUFUser.py.

00470 
00471     def authenticate(self, password, request):
00472         # We prevent groups from authenticating
00473         if self._isGroup:
00474             return None
00475         return self.__underlying__.authenticate(password, request)
00476 

def GroupUserFolder.GRUFUser.GRUFUserAtom.clearCachedGroupsAndRoles (   self,
  underlying_user = None 
) [inherited]

Definition at line 128 of file GRUFUser.py.

00128 
00129     def clearCachedGroupsAndRoles(self, underlying_user = None):
00130         self._groups = None
00131         self._user_roles = None
00132         self._group_roles = None
00133         self._all_roles = None
00134         if underlying_user:
00135             self._setUnderlying(underlying_user)
00136         self._original_user_roles = None

Here is the caller graph for this function:

...

Definition at line 173 of file GRUFUser.py.

00173 
00174     def getAllGroupIds(self,):
00175         """..."""
00176         return list(self._getGroups())

Here is the call graph for this function:

Here is the caller graph for this function:

...

Definition at line 167 of file GRUFUser.py.

00167 
00168     def getAllGroupNames(self,):
00169         """..."""
00170         ret = self._getGroups()
00171         return map(lambda x: x[GROUP_PREFIX_LEN:], ret)

Here is the call graph for this function:

Same as getAllGroupNames()

Definition at line 162 of file GRUFUser.py.

00162 
00163     def getAllGroups(self,):
00164         """Same as getAllGroupNames()"""
00165         return self.getAllGroupIds()

Here is the call graph for this function:

Return the list of domain restrictions for a user

Definition at line 401 of file GRUFUser.py.

00401 
00402     def getDomains(self):
00403         """Return the list of domain restrictions for a user"""
00404         return self._original_domains
00405 

...

Definition at line 157 of file GRUFUser.py.

00157 
00158     def getGroupIds(self,):
00159         """..."""
00160         return list(self._getGroups(no_recurse = 1))

Here is the call graph for this function:

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFGroup.getGroupMemberIds (   self,
  transitive = 1 
)
Return the members ids (groups only) of the groups of this group

Definition at line 874 of file GRUFUser.py.

00874 
00875     def getGroupMemberIds(self, transitive = 1, ):
00876         """Return the members ids (groups only) of the groups of this group"""
00877         return self._getMemberIds(users = 0, transitive = transitive)
    

Here is the call graph for this function:

...

Definition at line 151 of file GRUFUser.py.

00151 
00152     def getGroupNames(self,):
00153         """..."""
00154         ret = self._getGroups(no_recurse = 1)
00155         return map(lambda x: x[GROUP_PREFIX_LEN:], ret)

Here is the call graph for this function:

Return the tuple of roles belonging to this user's group(s)

Definition at line 326 of file GRUFUser.py.

00326 
00327     def getGroupRoles(self,):
00328         """
00329         Return the tuple of roles belonging to this user's group(s)
00330         """
00331         if self._group_roles is not None:
00332             return self._group_roles
00333         ret = []
00334         acl_users = self._GRUF.acl_users 
00335         groups = acl_users.getGroupIds()      # XXX We can have a cache here
00336         
00337         for group in self.getGroups():
00338             if not group in groups:
00339                 Log("Group", group, "is invalid. Ignoring.")
00340                 # This may occur when groups are deleted
00341                 # Ignored silently
00342                 continue
00343             ret.extend(acl_users.getGroup(group).getUserRoles())
00344 
00345         self._group_roles = GroupUserFolder.unique(ret)
00346         return self._group_roles

Here is the call graph for this function:

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.getGroups (   self,
  args,
  kw 
) [inherited]
...

Definition at line 178 of file GRUFUser.py.

00178 
00179     def getGroups(self, *args, **kw):
00180         """..."""
00181         ret = self._getGroups(*args, **kw)
00182         return list(ret)

Here is the call graph for this function:

Here is the caller graph for this function:

Same as getGroups but return them without a prefix.

Definition at line 250 of file GRUFUser.py.

00250 
00251     def getGroupsWithoutPrefix(self, **kw):
00252         """
00253         Same as getGroups but return them without a prefix.
00254         """
00255         ret = []
00256         for group in self.getGroups(**kw):
00257           if group.startswith(GROUP_PREFIX):
00258             ret.append(group[len(GROUP_PREFIX):])
00259         return ret

Here is the call graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.getId (   self,
  unprefixed = 0 
) [inherited]
Get the ID of the user. The ID can be used, at least from
Python, to get the user from the user's UserDatabase

Definition at line 290 of file GRUFUser.py.

00290 
00291     def getId(self, unprefixed = 0):
00292         """Get the ID of the user. The ID can be used, at least from
00293         Python, to get the user from the user's UserDatabase
00294         """
00295         # Return the right id
00296         if self.isGroup() and not self._original_name.startswith(GROUP_PREFIX) and not unprefixed:
00297             return "%s%s" % (GROUP_PREFIX, self._original_name)
00298         return self._original_name

Here is the call graph for this function:

Return NON-TRANSITIVE groups

Definition at line 184 of file GRUFUser.py.

00184 
00185     def getImmediateGroups(self,):
00186         """
00187         Return NON-TRANSITIVE groups
00188         """
00189         ret = self._getGroups(no_recurse = 1)
00190         return list(ret)
    

Here is the call graph for this function:

def GroupUserFolder.GRUFUser.GRUFGroup.getMemberIds (   self,
  transitive = 1 
)

Definition at line 864 of file GRUFUser.py.

00864 
00865     def getMemberIds(self, transitive = 1, ):
00866         "Return member ids of this group, including or not transitive groups."
00867         return self._getMemberIds(transitive = transitive)

Here is the call graph for this function:

Here is the caller graph for this function:

Get user's or group's name.
For a user, the name can be set by the underlying user folder but usually id == name.
For a group, the ID is prefixed, but the NAME is NOT prefixed by 'group_'.

Definition at line 277 of file GRUFUser.py.

00277 
00278     def getName(self,):
00279         """Get user's or group's name.
00280         For a user, the name can be set by the underlying user folder but usually id == name.
00281         For a group, the ID is prefixed, but the NAME is NOT prefixed by 'group_'.
00282         """
00283         return self.getUserNameWithoutGroupPrefix()

Here is the call graph for this function:

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.getProperty (   self,
  name,
  default = _marker 
) [inherited]
getProperty(self, name) => return property value or raise AttributeError

Definition at line 407 of file GRUFUser.py.

00407 
00408     def getProperty(self, name, default=_marker):
00409         """getProperty(self, name) => return property value or raise AttributeError
00410         """
00411         # Try to do an attribute lookup on the underlying user object
00412         v = getattr(self.__underlying__, name, default)
00413         if v is _marker:
00414             raise AttributeError, name
00415         return v

Here is the caller graph for this function:

Return group id WITHOUT group prefix

Reimplemented from GroupUserFolder.GRUFUser.GRUFUserAtom.

Definition at line 769 of file GRUFUser.py.

00769 
00770     def getRealId(self,):
00771         """Return group id WITHOUT group prefix
00772         """
00773         return self.getId()[len(GROUP_PREFIX):]
    
Return the list (tuple) of roles assigned to a user.
THIS IS WHERE THE ATHENIANS REACHED !

Definition at line 300 of file GRUFUser.py.

00300 
00301     def getRoles(self):
00302         """
00303         Return the list (tuple) of roles assigned to a user.
00304         THIS IS WHERE THE ATHENIANS REACHED !
00305         """
00306         if self._all_roles is not None:
00307             return self._all_roles
00308 
00309         # Return user and groups roles
00310         self._all_roles = GroupUserFolder.unique(self.getUserRoles() + self.getGroupRoles())
00311         return self._all_roles

Here is the call graph for this function:

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.getRolesInContext (   self,
  object,
  userid = None 
) [inherited]
Return the list of roles assigned to the user,
including local roles assigned in context of
the passed in object.

Definition at line 348 of file GRUFUser.py.

00348 
00349     def getRolesInContext(self, object, userid = None):
00350         """
00351         Return the list of roles assigned to the user,
00352         including local roles assigned in context of
00353         the passed in object.
00354         """
00355         if not userid:
00356             userid=self.getId()
00357 
00358         roles = {}
00359         for role in self.getRoles():
00360             roles[role] = 1
00361 
00362         user_groups = self.getGroups()
00363 
00364         inner_obj = getattr(object, 'aq_inner', object)
00365         while 1:
00366             # Usual local roles retreiving
00367             local_roles = getattr(inner_obj, '__ac_local_roles__', None)
00368             if local_roles:
00369                 if callable(local_roles):
00370                     local_roles = local_roles()
00371                 dict = local_roles or {}
00372 
00373                 for role in dict.get(userid, []):
00374                     roles[role] = 1
00375 
00376                 # Get roles & local roles for groups
00377                 # This handles nested groups as well
00378                 for groupid in user_groups:
00379                     for role in dict.get(groupid, []):
00380                         roles[role] = 1
00381                         
00382             # LocalRole blocking
00383             obj = getattr(inner_obj, 'aq_base', inner_obj)
00384             if getattr(obj, '__ac_local_roles_block__', None):
00385                 break
00386 
00387             # Loop management
00388             inner = getattr(inner_obj, 'aq_inner', inner_obj)
00389             parent = getattr(inner, 'aq_parent', None)
00390             if parent is not None:
00391                 inner_obj = parent
00392                 continue
00393             if hasattr(inner_obj, 'im_self'):
00394                 inner_obj=inner_obj.im_self
00395                 inner_obj=getattr(inner_obj, 'aq_inner', inner_obj)
00396                 continue
00397             break
00398 
00399         return tuple(roles.keys())

same as GRUF.getUnwrappedUser, but implicitly with this particular user

Definition at line 595 of file GRUFUser.py.

00595 
00596     def getUnwrappedUser(self,):
00597         """
00598         same as GRUF.getUnwrappedUser, but implicitly with this particular user
00599         """
00600         return self.__dict__['__underlying__']

Return the user id of a user

Definition at line 269 of file GRUFUser.py.

00269 
00270     def getUserId(self):
00271         """Return the user id of a user"""
00272         if self.isGroup() and \
00273           not self._original_name[:len(GROUP_PREFIX)] == GROUP_PREFIX:
00274             return "%s%s" % (GROUP_PREFIX, self._original_name )
00275         return self._original_name

Here is the call graph for this function:

def GroupUserFolder.GRUFUser.GRUFGroup.getUserMemberIds (   self,
  transitive = 1 
)
Return the member ids (users only) of the users of this group

Definition at line 869 of file GRUFUser.py.

00869 
00870     def getUserMemberIds(self, transitive = 1, ):
00871         """Return the member ids (users only) of the users of this group"""
00872         return self._getMemberIds(groups = 0, transitive = transitive)
    

Here is the call graph for this function:

Alias for getName()

Definition at line 285 of file GRUFUser.py.

00285 
00286     def getUserName(self,):
00287         """Alias for getName()"""
00288         return self.getUserNameWithoutGroupPrefix()
    

Here is the call graph for this function:

Here is the caller graph for this function:

Return the username of a user without a group prefix

Definition at line 261 of file GRUFUser.py.

00261 
00262     def getUserNameWithoutGroupPrefix(self):
00263         """Return the username of a user without a group prefix"""
00264         if self.isGroup() and \
00265           self._original_name[:len(GROUP_PREFIX)] == GROUP_PREFIX:
00266             return self._original_name[len(GROUP_PREFIX):]
00267         return self._original_name

Here is the call graph for this function:

Here is the caller graph for this function:

returns the roles defined for the user without the group roles

Definition at line 313 of file GRUFUser.py.

00313 
00314     def getUserRoles(self):
00315         """
00316         returns the roles defined for the user without the group roles
00317         """
00318         if self._user_roles is not None:
00319             return self._user_roles
00320         prefix = GROUP_PREFIX
00321         if self._original_user_roles is None:
00322             self._original_user_roles = self.__underlying__.getRoles()
00323         self._user_roles = tuple([r for r in self._original_user_roles if not r.startswith(prefix)])
00324         return self._user_roles

Here is the caller graph for this function:

getUserSourceId(self,) => string
Return the GRUF's GRUFUsers folder used to fetch this user.

Definition at line 143 of file GRUFUser.py.

00143 
00144     def getUserSourceId(self,):
00145         """
00146         getUserSourceId(self,) => string
00147         Return the GRUF's GRUFUsers folder used to fetch this user.
00148         """
00149         return self._source_id

Here is the caller graph for this function:

Return true if the specified atom id is in the group.
This is the contrary of IUserAtom.isInGroup(groupid)

Definition at line 879 of file GRUFUser.py.

00879 
00880     def hasMember(self, id):
00881         """Return true if the specified atom id is in the group.
00882         This is the contrary of IUserAtom.isInGroup(groupid)"""
00883         gruf = self.aq_parent
00884         return id in gruf.getMemberIds(self.getId())
    
def GroupUserFolder.GRUFUser.GRUFUserAtom.hasProperty (   self,
  name 
) [inherited]
hasProperty

Definition at line 417 of file GRUFUser.py.

00417 
00418     def hasProperty(self, name):
00419         """hasProperty"""
00420         return hasattr(self.__underlying__, name)

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.hasRole (   self,
  args,
  kw 
) [inherited]
hasRole is an alias for 'allowed' and has been deprecated.

Code still using this method should convert to either 'has_role' or
'allowed', depending on the intended behaviour.

Definition at line 569 of file GRUFUser.py.

00569 
00570     def hasRole(self, *args, **kw):
00571         """hasRole is an alias for 'allowed' and has been deprecated.
00572 
00573         Code still using this method should convert to either 'has_role' or
00574         'allowed', depending on the intended behaviour.
00575 
00576         """
00577         import warnings
00578         warnings.warn('BasicUser.hasRole is deprecated, please use '
00579             'BasicUser.allowed instead; hasRole was an alias for allowed, but '
00580             'you may have ment to use has_role.', DeprecationWarning)
00581         return self.allowed(*args, **kw)

Here is the call graph for this function:

Return 1 if this user is a group abstraction

Definition at line 138 of file GRUFUser.py.

00138 
00139     def isGroup(self,):
00140         """Return 1 if this user is a group abstraction"""
00141         return self._isGroup

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFUserAtom.isInGroup (   self,
  groupid 
) [inherited]
Return true if the user is member of the specified group id
(including transitive groups)

Definition at line 635 of file GRUFUser.py.

00635 
00636     def isInGroup(self, groupid):
00637         """Return true if the user is member of the specified group id
00638         (including transitive groups)"""
00639         return groupid in self.getAllGroupIds()

Here is the call graph for this function:

Remove a user from the current group

Definition at line 901 of file GRUFUser.py.

00901 
00902     def removeMember(self, userid):
00903         """Remove a user from the current group"""
00904         gruf = self.aq_parent
00905         groupid = self.getId()
00906 
00907         # Check the user
00908         usr = gruf.getUser(userid)
00909         if not usr:
00910             raise ValueError, "Invalid user: '%s'" % (userid, )
00911 
00912         # Now, remove the group
00913         groups = list(usr.getImmediateGroups())
00914         if groupid in groups:
00915             groups.remove(groupid)
00916             gruf._updateUser(userid, groups = groups)
00917         else:
00918             raise ValueError, "User '%s' doesn't belong to group '%s'" % (userid, groupid, )
    

Here is the caller graph for this function:

def GroupUserFolder.GRUFUser.GRUFGroup.setMembers (   self,
  userids 
)
Set the members of the group

Definition at line 920 of file GRUFUser.py.

00920 
00921     def setMembers(self, userids):
00922         """Set the members of the group
00923         """
00924         member_ids = self.getMemberIds()
00925         all_ids = copy(member_ids)
00926         all_ids.extend(userids)
00927         groupid = self.getId()
00928         for id in all_ids:
00929             if id in member_ids and id not in userids:
00930                 self.removeMember(id)
00931             elif id not in member_ids and id in userids:
00932                 self.addMember(id)
00933 
00934 
00935 InitializeClass(GRUFUser)
00936 InitializeClass(GRUFGroup)
def GroupUserFolder.GRUFUser.GRUFUserAtom.setProperty (   self,
  name,
  value 
) [inherited]
setProperty => Try to set the property...
By now, it's available only for LDAPUserFolder

Definition at line 422 of file GRUFUser.py.

00422 
00423     def setProperty(self, name, value):
00424         """setProperty => Try to set the property...
00425         By now, it's available only for LDAPUserFolder
00426         """
00427         # Get actual source
00428         src = self._GRUF.getUserSource(self.getUserSourceId())
00429         if not src:
00430             raise RuntimeError, "Invalid or missing user source for '%s'." % (self.getId(),)
00431 
00432         # LDAPUserFolder => specific API.
00433         if hasattr(src, "manage_setUserProperty"):
00434             # Unmap pty name if necessary, get it in the schema
00435             ldapname = None
00436             for schema in src.getSchemaConfig().values():
00437                 if schema["ldap_name"] == name:
00438                     ldapname = schema["ldap_name"]
00439                 if schema["public_name"] == name:
00440                     ldapname = schema["ldap_name"]
00441                     break
00442 
00443             # If we didn't find it, we skip it
00444             if ldapname is None:
00445                 raise KeyError, "Invalid LDAP attribute: '%s'." % (name, )
00446             
00447             # Edit user
00448             user_dn = src._find_user_dn(self.getUserName())
00449             src.manage_setUserProperty(user_dn, ldapname, value)
00450 
00451             # Expire the underlying user object
00452             self.__underlying__ = src.getUser(self.getId())
00453             if not self.__underlying__:
00454                 raise RuntimeError, "Error while setting property of '%s'." % (self.getId(),)
00455 
00456         # Now we check if the property has been changed
00457         if not self.hasProperty(name):
00458             raise NotImplementedError, "Property setting is not supported for '%s'." % (name,)
00459         v = self._GRUF.getUserById(self.getId()).getProperty(name)
00460         if not v == value:
00461             Log(LOG_DEBUG, "Property '%s' for user '%s' should be '%s' and not '%s'" % (
00462                 name, self.getId(), value, v,
00463                 ))
00464             raise NotImplementedError, "Property setting is not supported for '%s'." % (name,)


Member Data Documentation

tuple GroupUserFolder.GRUFUser.GRUFGroup.__implements__ = (IGroup, ) [static, private]

Definition at line 764 of file GRUFUser.py.

Definition at line 121 of file GRUFUser.py.

tuple GroupUserFolder.GRUFUser.GRUFGroup.security = ClassSecurityInfo() [static]

Reimplemented from GroupUserFolder.GRUFUser.GRUFUserAtom.

Definition at line 766 of file GRUFUser.py.


The documentation for this class was generated from the following file: