Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions
PlonePAS.tools.memberdata.MemberData Class Reference

List of all members.

Public Member Functions

def setMemberProperties
 setProperties uses setMemberProperties.
def getProperty
def getPassword
def canDelete
 IManageCapabilities methods.
def canPasswordSet
def passwordInClear
def canWriteProperty
def canAddToGroup
def canRemoveFromGroup
def canAssignRole

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Member Functions

def _memberdataHasProperty
def _getPlugins
 plugin getters

Detailed Description

Definition at line 104 of file memberdata.py.


Member Function Documentation

plugin getters

Definition at line 293 of file memberdata.py.

00293 
00294     def _getPlugins(self):
00295         return self.acl_users.plugins
00296 
00297 classImplements(MemberData,
00298                 implementedBy(BaseMemberData),
00299                 IManageCapabilities)
00300 
00301 InitializeClass(MemberData)

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.tools.memberdata.MemberData._memberdataHasProperty (   self,
  prop_name 
) [private]

Definition at line 224 of file memberdata.py.

00224 
00225     def _memberdataHasProperty(self, prop_name):
00226         mdata = getToolByName(self, 'portal_memberdata', None)
00227         if mdata:
00228             return mdata.hasProperty(prop_name)
00229         return 0

Here is the call graph for this function:

Here is the caller graph for this function:

True iff member can be added to group.

Definition at line 256 of file memberdata.py.

00256 
00257     def canAddToGroup(self, group_id):
00258         """True iff member can be added to group."""
00259         # IGroupManagement provides IGroupCapability
00260         plugins = self._getPlugins()
00261         managers = plugins.listPlugins(IGroupManagement)
00262         for mid, manager in managers:
00263             if (IGroupCapability.providedBy(manager) and
00264                     manager.allowGroupAdd(self.getId(), group_id)):
00265                 return True
00266         return False

True iff member can be assigned role. Role id is string.

Definition at line 279 of file memberdata.py.

00279 
00280     def canAssignRole(self, role_id):
00281         """True iff member can be assigned role. Role id is string."""
00282         # IRoleAssignerPlugin provides IAssignRoleCapability
00283         plugins = self._getPlugins()
00284         managers = plugins.listPlugins(IRoleAssignerPlugin)
00285         for mid, manager in managers:
00286             if (IAssignRoleCapability.providedBy(manager) and
00287                     manager.allowRoleAssign(self.getId(), role_id)):
00288                 return True
00289         return False

IManageCapabilities methods.

True iff user can be removed from the Plone UI.

Definition at line 194 of file memberdata.py.

00194 
00195     def canDelete(self):
00196         """True iff user can be removed from the Plone UI."""
00197         # IUserManagement provides doDeleteUser
00198         plugins = self._getPlugins()
00199         managers = plugins.listPlugins(IUserManagement)
00200         for mid, manager in managers:
00201             if (IDeleteCapability.providedBy(manager) and
00202                     manager.allowDeletePrincipal(self.getId())):
00203                 return True
00204         return False

True iff user can change password.

Definition at line 205 of file memberdata.py.

00205 
00206     def canPasswordSet(self):
00207         """True iff user can change password."""
00208         # IUserManagement provides doChangeUser
00209         plugins = self._getPlugins()
00210         managers = plugins.listPlugins(IUserManagement)
00211         for mid, manager in managers:
00212             if (IPasswordSetCapability.providedBy(manager) and
00213                     manager.allowPasswordSet(self.getId())):
00214                 return True
00215         return False

True iff member can be removed from group.

Definition at line 267 of file memberdata.py.

00267 
00268     def canRemoveFromGroup(self, group_id):
00269         """True iff member can be removed from group."""
00270         # IGroupManagement provides IGroupCapability
00271         plugins = self._getPlugins()
00272         managers = plugins.listPlugins(IGroupManagement)
00273         for mid, manager in managers:
00274             if (IGroupCapability.providedBy(manager) and
00275                     manager.allowGroupRemove(self.getId(), group_id)):
00276                 return True
00277         return False
00278 

True iff the member/group property named in 'prop_name'
can be changed.

Definition at line 230 of file memberdata.py.

00230 
00231     def canWriteProperty(self, prop_name):
00232         """True iff the member/group property named in 'prop_name'
00233         can be changed.
00234         """
00235         if not IPluggableAuthService.providedBy(self.acl_users):
00236             # not PAS; Memberdata is writable
00237             return self._memberdataHasProperty(prop_name)
00238         else:
00239             # it's PAS
00240             user = self.getUser()
00241             sheets = getattr(user, 'getOrderedPropertySheets', lambda: None)()
00242             if not sheets:
00243                 return self._memberdataHasProperty(prop_name)
00244 
00245             for sheet in sheets:
00246                 if not sheet.hasProperty(prop_name):
00247                     continue
00248                 if IMutablePropertySheet.providedBy(sheet):
00249                     # BBB for plugins implementing an older version of IMutablePropertySheet
00250                     if hasattr(sheet, 'canWriteProperty'):
00251                         return sheet.canWriteProperty(user, prop_name)
00252                     return True
00253                 else:
00254                     break  # shadowed by read-only
00255         return False

Here is the call graph for this function:

Returns None. Present to avoid NotImplementedError.

Definition at line 188 of file memberdata.py.

00188 
00189     def getPassword(self):
00190         """Returns None. Present to avoid NotImplementedError."""
00191         return None

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

Definition at line 151 of file memberdata.py.

00151 
00152     def getProperty(self, id, default=_marker):
00153         """PAS-specific method to fetch a user's properties. Looks
00154         through the ordered property sheets.
00155         """
00156         sheets = None
00157         if not IPluggableAuthService.providedBy(self.acl_users):
00158             return BaseMemberData.getProperty(self, id)
00159         else:
00160             # It's a PAS! Whee!
00161             user = self.getUser()
00162             sheets = getattr(user, 'getOrderedPropertySheets', lambda: None)()
00163 
00164             # we won't always have PlonePAS users, due to acquisition,
00165             # nor are guaranteed property sheets
00166             if not sheets:
00167                 return BaseMemberData.getProperty(self, id, default)
00168 
00169         charset = getCharset(self)
00170 
00171         # If we made this far, we found a PAS and some property sheets.
00172         for sheet in sheets:
00173             if sheet.hasProperty(id):
00174                 # Return the first one that has the property.
00175                 value = sheet.getProperty(id)
00176                 if isinstance(value, unicode):
00177                     # XXX Temporarily work around the fact that
00178                     # property sheets blindly store and return
00179                     # unicode. This is sub-optimal and should be
00180                     # dealed with at the property sheets level by
00181                     # using Zope's converters.
00182                     return value.encode(charset)
00183                 return value
00184 
00185         # Couldn't find the property in the property sheets. Try to
00186         # delegate back to the base implementation.
00187         return BaseMemberData.getProperty(self, id, default)

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 216 of file memberdata.py.

00216 
00217     def passwordInClear(self):
00218         """True iff password can be retrieved in the clear (not hashed.)
00219 
00220         False for PAS. It provides no API for getting passwords,
00221         though it would be possible to add one in the future.
00222         """
00223         return 0

def PlonePAS.tools.memberdata.MemberData.setMemberProperties (   self,
  mapping,
  force_local = 0 
)

setProperties uses setMemberProperties.

no need to override.

PAS-specific method to set the properties of a
member. Ignores 'force_local', which is not reliably present.

Definition at line 110 of file memberdata.py.

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

Here is the call graph for this function:


Member Data Documentation

tuple PlonePAS.tools.memberdata.MemberData.security = ClassSecurityInfo() [static]

Definition at line 106 of file memberdata.py.


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