Back to index

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

List of all members.

Public Member Functions

def __init__
def notifyModified
def getGroup
def getTool
def getGroupMemberIds
def getAllGroupMemberIds
def getGroupMembers
def getAllGroupMembers
def canAdministrateGroup
def addMember
def removeMember
def setProperties
def setGroupProperties
def getProperties
def getProperty
def __str__
def isGroup
def getGroupName
 Group object interface ###.
def getGroupId
def getGroupTitleOrName
def getMemberId
def getRoles
def getRolesInContext
def getDomains
def has_role

Static Public Attributes

tuple security = ClassSecurityInfo()
 id = None
tuple addMember = postonly(addMember)
tuple removeMember = postonly(removeMember)

Private Member Functions

def _getGRUF
def _getGroup

Static Private Attributes

 __implements__ = IGroupData
 _tool = None

Detailed Description

Definition at line 139 of file GroupDataTool.py.


Constructor & Destructor Documentation

def GroupUserFolder.GroupDataTool.GroupData.__init__ (   self,
  tool,
  id 
)

Definition at line 148 of file GroupDataTool.py.

00148 
00149     def __init__(self, tool, id):
00150         self.id = id
00151         # Make a temporary reference to the tool.
00152         # The reference will be removed by notifyModified().
00153         self._tool = tool


Member Function Documentation

Definition at line 377 of file GroupDataTool.py.

00377 
00378     def __str__(self):
00379         return self.getGroupId()

Here is the call graph for this function:

_getGroup(self,) => Get the underlying group object

Definition at line 235 of file GroupDataTool.py.

00235 
00236     def _getGroup(self,):
00237         """
00238         _getGroup(self,) => Get the underlying group object
00239         """
00240         return self._getGRUF().getGroupByName(self.getGroupName())
00241 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 154 of file GroupDataTool.py.

00154 
00155     def _getGRUF(self,):
00156         return self.acl_users

Here is the caller graph for this function:

def GroupUserFolder.GroupDataTool.GroupData.addMember (   self,
  id,
  REQUEST = None 
)
Add the existing member with the given id to the group

Definition at line 274 of file GroupDataTool.py.

00274 
00275     def addMember(self, id, REQUEST=None):
00276         """ Add the existing member with the given id to the group"""
00277         # We check if the current user can directly or indirectly administrate this group
00278         if not self.canAdministrateGroup():
00279             raise Unauthorized, "You cannot add a member to the group."
00280         self._getGroup().addMember(id)
00281 
00282         # Notify member that they've been changed
00283         mtool = getToolByName(self, 'portal_membership')
00284         member = mtool.getMemberById(id)
00285         if member:
            member.notifyModified()

Here is the call graph for this function:

Here is the caller graph for this function:

Return true if the #current# user can administrate this group

Definition at line 243 of file GroupDataTool.py.

00243 
00244     def canAdministrateGroup(self,):
00245         """
00246         Return true if the #current# user can administrate this group
00247         """
00248         user = getSecurityManager().getUser()
00249         tool = self.getTool()
00250         portal = getToolByName(tool, 'portal_url').getPortalObject()
00251         
00252         # Has manager users pemission? 
00253         if user.has_permission(Permissions.manage_users, portal):
00254             return True
00255 
00256         # Is explicitly mentioned as a group administrator?
00257         managers = self.getProperty('delegated_group_member_managers', ())
00258         if user.getId() in managers:
00259             return True
00260 
00261         # Belongs to a group which is explicitly mentionned as a group administrator
00262         meth = getattr(user, "getAllGroupNames", None)
00263         if meth:
00264             groups = meth()
00265         else:
00266             groups = ()
00267         for v in groups:
00268             if v in managers:
00269                 return True
00270 
00271         # No right to edit this: we complain.
00272         return False

Here is the call graph for this function:

Here is the caller graph for this function:

Return a list of group member ids

Definition at line 191 of file GroupDataTool.py.

00191 
00192     def getAllGroupMemberIds(self,):
00193         """
00194         Return a list of group member ids
00195         """
00196         return map(lambda x: x.getMemberId(), self.getAllGroupMembers())

Here is the call graph for this function:

Returns a list of the portal_memberdata-ish members of the group.
This will include transitive groups / users

Definition at line 217 of file GroupDataTool.py.

00217 
00218     def getAllGroupMembers(self, ):
00219         """
00220         Returns a list of the portal_memberdata-ish members of the group.
00221         This will include transitive groups / users
00222         """
00223         md = self.portal_memberdata
00224         gd = self.portal_groupdata
00225         ret = []
00226         for u_name in self.getGroup().getMemberIds():
00227             usr = self._getGRUF().getUserById(u_name)
00228             if not usr:
00229                 raise AssertionError, "Cannot retreive a user by its id !"
00230             if usr.isGroup():
00231                 ret.append(gd.wrapGroup(usr))
00232             else:
00233                 ret.append(md.wrapUser(usr))
00234         return ret

Here is the call graph for this function:

Here is the caller graph for this function:

Return the list of domain restrictions for a user

Definition at line 431 of file GroupDataTool.py.

00431 
00432     def getDomains(self):
00433         """Return the list of domain restrictions for a user"""
00434         return self.getGroup().getDomains()

Here is the call graph for this function:

Returns the actual group implementation. Varies by group
implementation (GRUF/Nux/et al). In GRUF this is a user object.

Definition at line 166 of file GroupDataTool.py.

00166 
00167     def getGroup(self):
00168         """ Returns the actual group implementation. Varies by group
00169         implementation (GRUF/Nux/et al). In GRUF this is a user object."""
00170         # The user object is our context, but it's possible for
00171         # restricted code to strip context while retaining
00172         # containment.  Therefore we need a simple security check.
00173         parent = aq_parent(self)
00174         bcontext = aq_base(parent)
00175         bcontainer = aq_base(aq_parent(aq_inner(self)))
00176         if bcontext is bcontainer or not hasattr(bcontext, 'getUserName'):
00177             raise 'GroupDataError', "Can't find group data"
00178         # Return the user object, which is our context.
00179         return parent

Here is the caller graph for this function:

Get the ID of the group. The ID can be used, at least from
Python, to get the user from the user's UserDatabase.
Within Plone, all group ids are UNPREFIXED.

Definition at line 398 of file GroupDataTool.py.

00398 
00399     def getGroupId(self):
00400         """Get the ID of the group. The ID can be used, at least from
00401         Python, to get the user from the user's UserDatabase.
00402         Within Plone, all group ids are UNPREFIXED."""
00403         if isinstance(self, GRUFGroup):
00404             return self.getGroup().getId(unprefixed = 1)
00405         else:
00406             return self.getGroup().getId()

Here is the call graph for this function:

Here is the caller graph for this function:

Return a list of group member ids

Definition at line 184 of file GroupDataTool.py.

00184 
00185     def getGroupMemberIds(self,):
00186         """
00187         Return a list of group member ids
00188         """
00189         return map(lambda x: x.getMemberId(), self.getGroupMembers())

Here is the call graph for this function:

Returns a list of the portal_memberdata-ish members of the group.
This doesn't include TRANSITIVE groups/users.

Definition at line 198 of file GroupDataTool.py.

00198 
00199     def getGroupMembers(self, ):
00200         """
00201         Returns a list of the portal_memberdata-ish members of the group.
00202         This doesn't include TRANSITIVE groups/users.
00203         """
00204         md = self.portal_memberdata
00205         gd = self.portal_groupdata
00206         ret = []
00207         for u_name in self.getGroup().getMemberIds(transitive = 0, ):
00208             usr = self._getGRUF().getUserById(u_name)
00209             if not usr:
00210                 raise AssertionError, "Cannot retreive a user by its id !"
00211             if usr.isGroup():
00212                 ret.append(gd.wrapGroup(usr))
00213             else:
00214                 ret.append(md.wrapUser(usr))
00215         return ret

Here is the call graph for this function:

Here is the caller graph for this function:

Group object interface ###.

Return the name of the group, without any special decorations (like GRUF prefixes.)

Definition at line 393 of file GroupDataTool.py.

00393 
00394     def getGroupName(self):
00395         """Return the name of the group, without any special decorations (like GRUF prefixes.)"""
00396         return self.getGroup().getName()

Here is the call graph for this function:

Here is the caller graph for this function:

Get the Title property of the group. If there is none
then return the name 

Definition at line 407 of file GroupDataTool.py.

00407 
00408     def getGroupTitleOrName(self):
00409         """Get the Title property of the group. If there is none
00410         then return the name """
00411         title = self.getProperty('title', None)
00412         return title or self.getGroupName()

Here is the call graph for this function:

This exists only for a basic user/group API compatibility

Definition at line 414 of file GroupDataTool.py.

00414 
00415     def getMemberId(self,):
00416         """This exists only for a basic user/group API compatibility
00417         """
00418         return self.getGroupId()

Here is the call graph for this function:

Return the properties of this group. Properties are as usual in Zope.

Definition at line 334 of file GroupDataTool.py.

00334 
00335     def getProperties(self, ):
00336         """ Return the properties of this group. Properties are as usual in Zope."""
00337         tool = self.getTool()
00338         ret = {}
00339         for pty in tool.propertyIds():
00340             try:
00341                 ret[pty] = self.getProperty(pty)
00342             except ValueError:
00343                 # We ignore missing ptys
00344                 continue
00345         return ret

Here is the call graph for this function:

def GroupUserFolder.GroupDataTool.GroupData.getProperty (   self,
  id,
  default = _marker 
)
Returns the value of the property specified by 'id' 

Definition at line 347 of file GroupDataTool.py.

00347 
00348     def getProperty(self, id, default=_marker):
00349         """ Returns the value of the property specified by 'id' """
00350         tool = self.getTool()
00351         base = aq_base( self )
00352 
00353         # First, check the wrapper (w/o acquisition).
00354         value = getattr( base, id, _marker )
00355         if value is not _marker:
00356             return value
00357 
00358         # Then, check the tool and the user object for a value.
00359         tool_value = tool.getProperty( id, _marker )
00360         user_value = getattr( aq_base(self.getGroup()), id, _marker )
00361 
00362         # If the tool doesn't have the property, use user_value or default
00363         if tool_value is _marker:
00364             if user_value is not _marker:
00365                 return user_value
00366             elif default is not _marker:
00367                 return default
00368             else:
00369                 raise ValueError, 'The property %s does not exist' % id
00370 
00371         # If the tool has an empty property and we have a user_value, use it
00372         if not tool_value and user_value is not _marker:
00373             return user_value
00374 
00375         # Otherwise return the tool value
00376         return tool_value

Here is the call graph for this function:

Here is the caller graph for this function:

Return the list of roles assigned to a user.

Definition at line 420 of file GroupDataTool.py.

00420 
00421     def getRoles(self):
00422         """Return the list of roles assigned to a user."""
00423         return self.getGroup().getRoles()

Here is the call graph for this function:

Here is the caller graph for this function:

Return the list of roles assigned to the user,  including local
roles assigned in context of the passed in object.

Definition at line 425 of file GroupDataTool.py.

00425 
00426     def getRolesInContext(self, object):
00427         """Return the list of roles assigned to the user,  including local
00428         roles assigned in context of the passed in object."""
00429         return self.getGroup().getRolesInContext(object)

Here is the call graph for this function:

Definition at line 180 of file GroupDataTool.py.

00180 
00181     def getTool(self):
00182         return aq_parent(aq_inner(self))

Here is the caller graph for this function:

def GroupUserFolder.GroupDataTool.GroupData.has_role (   self,
  roles,
  object = None 
)
Check to see if a user has a given role or roles.

Definition at line 436 of file GroupDataTool.py.

00436 
00437     def has_role(self, roles, object=None):
00438         """Check to see if a user has a given role or roles."""
00439         return self.getGroup().has_role(roles, object)

Here is the call graph for this function:

isGroup(self,) => Return true if this is a group.
Will always return true for groups.
As MemberData objects do not support this method, it is quite useless by now.
So one can use groupstool.isGroup(g) instead to get this information.

Definition at line 381 of file GroupDataTool.py.

00381 
00382     def isGroup(self,):
00383         """
00384         isGroup(self,) => Return true if this is a group.
00385         Will always return true for groups.
00386         As MemberData objects do not support this method, it is quite useless by now.
00387         So one can use groupstool.isGroup(g) instead to get this information.
00388         """
00389         return 1

Here is the caller graph for this function:

Definition at line 158 of file GroupDataTool.py.

00158 
00159     def notifyModified(self):
00160         # Links self to parent for full persistence.
00161         tool = getattr(self, '_tool', None)
00162         if tool is not None:
00163             del self._tool
00164             tool.registerGroupData(self, self.getId())

Here is the caller graph for this function:

def GroupUserFolder.GroupDataTool.GroupData.removeMember (   self,
  id,
  REQUEST = None 
)
Remove the member with the provided id from the group.

Definition at line 289 of file GroupDataTool.py.

00289 
00290     def removeMember(self, id, REQUEST=None):
00291         """Remove the member with the provided id from the group.
00292         """
00293         # We check if the current user can directly or indirectly administrate this group
00294         if not self.canAdministrateGroup():
00295             raise Unauthorized, "You cannot remove a member from the group."
00296         self._getGroup().removeMember(id)
00297 
00298         # Notify member that they've been changed
00299         mtool = getToolByName(self, 'portal_membership')
00300         member = mtool.getMemberById(id)
00301         if member:
            member.notifyModified()

Here is the call graph for this function:

Here is the caller graph for this function:

Sets the properties of the member.

Definition at line 315 of file GroupDataTool.py.

00315 
00316     def setGroupProperties(self, mapping):
00317         '''Sets the properties of the member.
00318         '''
00319         # Sets the properties given in the MemberDataTool.
00320         tool = self.getTool()
00321         for id in tool.propertyIds():
00322             if mapping.has_key(id):
00323                 if not self.__class__.__dict__.has_key(id):
00324                     value = mapping[id]
00325                     if type(value)==type(''):
00326                         proptype = tool.getPropertyType(id) or 'string'
00327                         if type_converters.has_key(proptype):
00328                             value = type_converters[proptype](value)
00329                     setattr(self, id, value)
00330                     
00331         # Hopefully we can later make notifyModified() implicit.
00332         self.notifyModified()

Here is the call graph for this function:

Here is the caller graph for this function:

def GroupUserFolder.GroupDataTool.GroupData.setProperties (   self,
  properties = None,
  kw 
)
Allows the manager group to set his/her own properties.
Accepts either keyword arguments or a mapping for the "properties"
argument.

Definition at line 305 of file GroupDataTool.py.

00305 
00306     def setProperties(self, properties=None, **kw):
00307         '''Allows the manager group to set his/her own properties.
00308         Accepts either keyword arguments or a mapping for the "properties"
00309         argument.
00310         '''
00311         if properties is None:
00312             properties = kw
00313         return self.setGroupProperties(properties)

Here is the call graph for this function:


Member Data Documentation

Definition at line 141 of file GroupDataTool.py.

Definition at line 146 of file GroupDataTool.py.

Definition at line 286 of file GroupDataTool.py.

Definition at line 145 of file GroupDataTool.py.

Definition at line 302 of file GroupDataTool.py.

tuple GroupUserFolder.GroupDataTool.GroupData.security = ClassSecurityInfo() [static]

Definition at line 143 of file GroupDataTool.py.


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