Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
PlonePAS.tools.groupdata.GroupData Class Reference

List of all members.

Public Member Functions

def setGroupProperties
 setProperties uses setGroupProperties.
def getProperty
def getUserName
def getGroupName
def addMember
def removeMember
def getAllGroupMembers
def getGroupMembers
def setProperties
def getProperties
def canDelete
 IManageCapabilities methods.
def canPasswordSet
def passwordInClear
def canWriteProperty

Static Public Attributes

tuple security = ClassSecurityInfo()
 getUserNameWithoutGroupPrefix = getUserName
 canAddToGroup = MemberData.canAddToGroup.im_func
 canRemoveFromGroup = MemberData.canRemoveFromGroup.im_func
 canAssignRole = MemberData.canAssignRole.im_func

Private Member Functions

def _getGroup
def _getGRUF
 GRUF 3.2 methods...
def _groupdataHasProperty
def _getPlugins
 plugin getters

Detailed Description

Definition at line 103 of file groupdata.py.


Member Function Documentation

Get the underlying group object in a PAS-acceptable way.
(I don't even know why there's the two different ways for GRUF. Speed?)

Definition at line 107 of file groupdata.py.

00107 
00108     def _getGroup(self):
00109         """Get the underlying group object in a PAS-acceptable way.
00110         (I don't even know why there's the two different ways for GRUF. Speed?)
00111         """
00112         return self.getGroup()

Here is the call graph for this function:

GRUF 3.2 methods...

Definition at line 186 of file groupdata.py.

00186 
00187     def _getGRUF(self,):
00188         return self.acl_users

Here is the caller graph for this function:

plugin getters

Definition at line 346 of file groupdata.py.

00346 
00347     def _getPlugins(self):
00348         return self.acl_users.plugins
00349 
00350 classImplements(GroupData,
00351                 implementedBy(BaseGroupData),
00352                 IManageCapabilities)
00353 
00354 InitializeClass(GroupData)

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.tools.groupdata.GroupData._groupdataHasProperty (   self,
  prop_name 
) [private]

Definition at line 309 of file groupdata.py.

00309 
00310     def _groupdataHasProperty(self, prop_name):
00311         gdata = getToolByName(self, 'portal_groupdata', None)
00312         if gdata:
00313             return gdata.hasProperty(prop_name)
00314         return 0

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 190 of file groupdata.py.

00190 
00191     def addMember(self, id, REQUEST=None):
00192         """ Add the existing member with the given id to the group"""
00193         if not self.canAdministrateGroup():
00194             raise Unauthorized, "You cannot add a member to the group."
00195         
00196         plugins = self._getPlugins()
00197         managers = plugins.listPlugins(IGroupManagement)
00198         for mid, manager in managers:
00199             try:
00200                 if manager.addPrincipalToGroup(id, self.getId()):
00201                     break
00202             except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00203                 pass

IManageCapabilities methods.

True iff user can be removed from the Plone UI.

Definition at line 283 of file groupdata.py.

00283 
00284     def canDelete(self):
00285         """True iff user can be removed from the Plone UI.
00286         """
00287         # IGroupManagement provides removeGroup
00288         plugins = self._getPlugins()
00289         managers = plugins.listPlugins(IGroupManagement)
00290         if managers:
00291             for mid, manager in managers:
00292                 if (IDeleteCapability.providedBy(manager) and
00293                         manager.allowDeletePrincipal(self.getId())):
00294                     return True
00295         return False

Always false for groups, which have no password.

Definition at line 296 of file groupdata.py.

00296 
00297     def canPasswordSet(self):
00298         """Always false for groups, which have no password.
00299         """
00300         return False

def PlonePAS.tools.groupdata.GroupData.canWriteProperty (   self,
  prop_name 
)
True iff the group property named in 'prop_name'
can be changed.

Definition at line 315 of file groupdata.py.

00315 
00316     def canWriteProperty(self, prop_name):
00317         """True iff the group property named in 'prop_name'
00318         can be changed.
00319         """
00320         # this looks almost exactly like in memberdata. refactor?
00321         if not IPluggableAuthService.providedBy(self.acl_users):
00322             # not PAS; Groupdata is writable
00323             return self._groupdataHasProperty(prop_name)
00324         else:
00325             # it's PAS
00326             group = self.getGroup()
00327             sheets = getattr(group, 'getOrderedPropertySheets', lambda: None)()
00328             if not sheets:
00329                 return self._groupdataHasProperty(prop_name)
00330 
00331             for sheet in sheets:
00332                 if not sheet.hasProperty(prop_name):
00333                     continue
00334                 if IMutablePropertySheet.providedBy(sheet):
00335                     return 1
00336                 else:
00337                     break  # shadowed by read-only
00338         return 0

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 221 of file groupdata.py.

00221 
00222     def getAllGroupMembers(self, ):
00223         """
00224         Returns a list of the portal_memberdata-ish members of the group.
00225         This will include transitive groups / users
00226         """
00227         md = self.portal_memberdata
00228         gd = self.portal_groupdata
00229         ret = []
00230         for u_name in self.getGroup().getMemberIds():
00231             usr = self._getGRUF().getUserById(u_name)
00232             if not usr:
00233                 logger.debug("Group has a non-existing user %s" % u_name)
00234                 continue
00235             if usr.isGroup():
00236                 ret.append(gd.wrapGroup(usr))
00237             else:
00238                 ret.append(md.wrapUser(usr))
00239         return ret

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 240 of file groupdata.py.

00240 
00241     def getGroupMembers(self):
00242         """
00243         Returns a list of the portal_memberdata-ish members of the group.
00244         This doesn't include TRANSITIVE groups/users.
00245         """
00246         md = self.portal_memberdata
00247         gd = self.portal_groupdata
00248         gtool = self.portal_groups
00249         ret = []
00250         for u_name in gtool.getGroupMembers(self.getId()):
00251             usr = self._getGRUF().getUserById(u_name)
00252             if not usr:
00253                 logger.debug("Group has a non-existing user %s" % u_name)
00254                 continue
00255             elif usr.isGroup():
00256                 ret.append(gd.wrapGroup(usr))
00257             else:
00258                 ret.append(md.wrapUser(usr))
00259         return ret

Definition at line 181 of file groupdata.py.

00181 
00182     def getGroupName(self):
00183         return self.getName()

Here is the call graph for this function:

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

Definition at line 269 of file groupdata.py.

00269 
00270     def getProperties(self):
00271         """ Return the properties of this group. Properties are as usual in Zope.
00272         """
00273         tool = self.getTool()
00274         ret = {}
00275         for pty in tool.propertyIds():
00276             try:
00277                 ret[pty] = self.getProperty(pty)
00278             except ValueError:
00279                 # We ignore missing ptys
00280                 continue
00281         return ret

Here is the call graph for this function:

def PlonePAS.tools.groupdata.GroupData.getProperty (   self,
  id,
  default = _marker 
)
PAS-specific method to fetch a group's properties. Looks
through the ordered property sheets.

Definition at line 152 of file groupdata.py.

00152 
00153     def getProperty(self, id, default=_marker):
00154         """PAS-specific method to fetch a group's properties. Looks
00155         through the ordered property sheets.
00156         """
00157         sheets = None
00158         if not IPluggableAuthService.providedBy(self.acl_users):
00159             return BaseGroupData.getProperty(self, id)
00160         else:
00161             # It's a PAS! Whee!
00162             group = self.getGroup()
00163             sheets = getattr(group, 'getOrderedPropertySheets', lambda: None)()
00164             # we won't always have PlonePAS groups, due to acquisition,
00165             # nor are guaranteed property sheets
00166             if not sheets:
00167                 return BaseGroupData.getProperty(self, id)
00168 
00169         # If we made this far, we found a PAS and some property sheets.
00170         for sheet in sheets:
00171             if sheet.hasProperty(id):
00172                 # Return the first one that has the property.
00173                 return sheet.getProperty(id)
00174         # Couldn't find the property in the property sheets. Try to
00175         # delegate back to the base implementation.
00176         return BaseGroupData.getProperty(self, id, default)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 177 of file groupdata.py.

00177 
00178     def getUserName(self):
        return self.getName()

Here is the call graph for this function:

Here is the caller graph for this function:

True iff password can be retrieved in the clear (not hashed.)

False for PAS. It provides no API for getting passwords,
though it would be possible to add one in the future.

Definition at line 301 of file groupdata.py.

00301 
00302     def passwordInClear(self):
00303         """True iff password can be retrieved in the clear (not hashed.)
00304 
00305         False for PAS. It provides no API for getting passwords,
00306         though it would be possible to add one in the future.
00307         """
00308         return Flase

def PlonePAS.tools.groupdata.GroupData.removeMember (   self,
  id,
  REQUEST = None 
)
Remove the member with the provided id from the group.

Definition at line 205 of file groupdata.py.

00205 
00206     def removeMember(self, id, REQUEST=None):
00207         """Remove the member with the provided id from the group.
00208         """
00209         if not self.canAdministrateGroup():
00210             raise Unauthorized, "You cannot remove a member from the group."
00211 
00212         plugins = self._getPlugins()
00213         managers = plugins.listPlugins(IGroupManagement)
00214         for mid, manager in managers:
00215             try:
00216                 if manager.removePrincipalFromGroup(id, self.getId()):
00217                     break
00218             except _SWALLOWABLE_PLUGIN_EXCEPTIONS:
00219                 pass
00220 

setProperties uses setGroupProperties.

no need to override.

PAS-specific method to set the properties of a group.

Definition at line 114 of file groupdata.py.

00114 
00115     def setGroupProperties(self, mapping):
00116         """PAS-specific method to set the properties of a group.
00117         """
00118         sheets = None
00119 
00120         if not IPluggableAuthService.providedBy(self.acl_users):
00121             # Defer to base impl in absence of PAS, a PAS group, or
00122             # property sheets
00123             return BaseGroupData.setGroupProperties(self, mapping)
00124         else:
00125             # It's a PAS! Whee!
00126             group = self.getGroup()
00127             sheets = getattr(group, 'getOrderedPropertySheets', lambda: None)()
00128 
00129             # We won't always have PlonePAS groups, due to acquisition,
00130             # nor are guaranteed property sheets
00131             if not sheets:
00132                 # Defer to base impl if we have a PAS but no property
00133                 # sheets.
00134                 return BaseGroupData.setGroupProperties(self, mapping)
00135 
00136         # If we got this far, we have a PAS and some property sheets.
00137         # XXX track values set to defer to default impl
00138         # property routing?
00139         modified = False
00140         for k, v in mapping.items():
00141             for sheet in sheets:
00142                 if not sheet.hasProperty(k):
00143                     continue
00144                 if IMutablePropertySheet.providedBy(sheet):
00145                     sheet.setProperty(group, k, v)
00146                     modified = True
00147                 else:
00148                     raise RuntimeError, ("Mutable property provider "
00149                                          "shadowed by read only provider")
00150         if modified:
00151             self.notifyModified()

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.tools.groupdata.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 260 of file groupdata.py.

00260 
00261     def setProperties(self, properties=None, **kw):
00262         """Allows the manager group to set his/her own properties.
00263         Accepts either keyword arguments or a mapping for the "properties"
00264         argument.
00265         """
00266         if properties is None:
00267             properties = kw
00268         return self.setGroupProperties(properties)

Here is the call graph for this function:


Member Data Documentation

PlonePAS.tools.groupdata.GroupData.canAddToGroup = MemberData.canAddToGroup.im_func [static]

Definition at line 339 of file groupdata.py.

PlonePAS.tools.groupdata.GroupData.canAssignRole = MemberData.canAssignRole.im_func [static]

Definition at line 341 of file groupdata.py.

PlonePAS.tools.groupdata.GroupData.canRemoveFromGroup = MemberData.canRemoveFromGroup.im_func [static]

Definition at line 340 of file groupdata.py.

Definition at line 179 of file groupdata.py.

tuple PlonePAS.tools.groupdata.GroupData.security = ClassSecurityInfo() [static]

Definition at line 105 of file groupdata.py.


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