Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
CMFCore.MemberDataTool.MemberData Class Reference
Inheritance diagram for CMFCore.MemberDataTool.MemberData:
Inheritance graph
[legend]
Collaboration diagram for CMFCore.MemberDataTool.MemberData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def notifyModified
def getUser
def getTool
def getMemberId
def setProperties
def setMemberProperties
def getProperty
def getPassword
def setSecurityProfile
def __str__
def getUserName
 User object interface ###.
def getId
def getRoles
def getRolesInContext
def getDomains
def has_role

Public Attributes

 id

Static Public Attributes

tuple security = ClassSecurityInfo()

Static Private Attributes

 __implements__ = z2IMemberData

Detailed Description

Definition at line 242 of file MemberDataTool.py.


Constructor & Destructor Documentation

def CMFCore.MemberDataTool.MemberData.__init__ (   self,
  tool,
  id 
)

Definition at line 249 of file MemberDataTool.py.

00249 
00250     def __init__(self, tool, id):
00251         self.id = id


Member Function Documentation

Definition at line 370 of file MemberDataTool.py.

00370 
00371     def __str__(self):
00372         return self.getMemberId()

Here is the call graph for this function:

Return the list of domain restrictions for a user

Definition at line 400 of file MemberDataTool.py.

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

Here is the call graph for this function:

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 381 of file MemberDataTool.py.

00381 
00382     def getId(self):
00383         """Get the ID of the user. The ID can be used, at least from
00384         Python, to get the user from the user's
00385         UserDatabase"""
00386         return self.getUser().getId()

Here is the call graph for this function:

Definition at line 274 of file MemberDataTool.py.

00274 
00275     def getMemberId(self):
00276         return self.getUser().getId()

Here is the call graph for this function:

Here is the caller graph for this function:

Return the password of the user.

Definition at line 351 of file MemberDataTool.py.

00351 
00352     def getPassword(self):
00353         """Return the password of the user."""
00354         return self.getUser()._getPassword()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.MemberDataTool.MemberData.getProperty (   self,
  id,
  default = _marker 
)

Definition at line 320 of file MemberDataTool.py.

00320 
00321     def getProperty(self, id, default=_marker):
00322 
00323         tool = self.getTool()
00324         base = aq_base( self )
00325 
00326         # First, check the wrapper (w/o acquisition).
00327         value = getattr( base, id, _marker )
00328         if value is not _marker:
00329             return value
00330 
00331         # Then, check the tool and the user object for a value.
00332         tool_value = tool.getProperty( id, _marker )
00333         user_value = getattr( self.getUser(), id, _marker )
00334 
00335         # If the tool doesn't have the property, use user_value or default
00336         if tool_value is _marker:
00337             if user_value is not _marker:
00338                 return user_value
00339             elif default is not _marker:
00340                 return default
00341             else:
00342                 raise ValueError, 'The property %s does not exist' % id
00343 
00344         # If the tool has an empty property and we have a user_value, use it
00345         if not tool_value and user_value is not _marker:
00346             return user_value
00347 
00348         # Otherwise return the tool value
00349         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 388 of file MemberDataTool.py.

00388 
00389     def getRoles(self):
00390         """Return the list of roles assigned to a user."""
00391         return self.getUser().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 393 of file MemberDataTool.py.

00393 
00394     def getRolesInContext(self, object):
00395         """Return the list of roles assigned to the user,
00396            including local roles assigned in context of
00397            the passed in object."""
00398         return self.getUser().getRolesInContext(object)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 270 of file MemberDataTool.py.

00270 
00271     def getTool(self):
00272         return aq_parent(aq_inner(self))

Here is the caller graph for this function:

Definition at line 258 of file MemberDataTool.py.

00258 
00259     def getUser(self):
00260         # The user object is our context, but it's possible for
00261         # restricted code to strip context while retaining
00262         # containment.  Therefore we need a simple security check.
00263         parent = aq_parent(self)
00264         bcontext = aq_base(parent)
00265         bcontainer = aq_base(aq_parent(aq_inner(self)))
00266         if bcontext is bcontainer or not hasattr(bcontext, 'getUserName'):
00267             raise 'MemberDataError', "Can't find user data"
00268         # Return the user object, which is our context.
00269         return parent

Here is the caller graph for this function:

User object interface ###.

Return the username of a user

Definition at line 376 of file MemberDataTool.py.

00376 
00377     def getUserName(self):
00378         """Return the username of a user"""
00379         return self.getUser().getUserName()

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFCore.MemberDataTool.MemberData.has_role (   self,
  roles,
  object = None 
)
Check to see if a user has a given role or roles.

Definition at line 405 of file MemberDataTool.py.

00405 
00406     def has_role(self, roles, object=None):
00407         """Check to see if a user has a given role or roles."""
00408         return self.getUser().has_role(roles, object)

Here is the call graph for this function:

Definition at line 253 of file MemberDataTool.py.

00253 
00254     def notifyModified(self):
00255         # Links self to parent for full persistence.
00256         self.getTool().registerMemberData(self, self.getId())

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 300 of file MemberDataTool.py.

00300 
00301     def setMemberProperties(self, mapping):
00302         '''Sets the properties of the member.
00303         '''
00304         # Sets the properties given in the MemberDataTool.
00305         tool = self.getTool()
00306         for id in tool.propertyIds():
00307             if mapping.has_key(id):
00308                 if not self.__class__.__dict__.has_key(id):
00309                     value = mapping[id]
00310                     if type(value)==type(''):
00311                         proptype = tool.getPropertyType(id) or 'string'
00312                         if type_converters.has_key(proptype):
00313                             value = type_converters[proptype](value)
00314                     setattr(self, id, value)
00315         # Hopefully we can later make notifyModified() implicit.
00316         self.notifyModified()

Here is the call graph for this function:

def CMFCore.MemberDataTool.MemberData.setProperties (   self,
  properties = None,
  kw 
)
Allows the authenticated member to set his/her own properties.
Accepts either keyword arguments or a mapping for the "properties"
argument.

Definition at line 278 of file MemberDataTool.py.

00278 
00279     def setProperties(self, properties=None, **kw):
00280         '''Allows the authenticated member to set his/her own properties.
00281         Accepts either keyword arguments or a mapping for the "properties"
00282         argument.
00283         '''
00284         # XXX: this method violates the rules for tools/utilities:
00285         # it depends on a non-utility tool
00286         if properties is None:
00287             properties = kw
00288         membership = getToolByName(self, 'portal_membership')
00289         registration = getToolByName(self, 'portal_registration', None)
00290         if not membership.isAnonymousUser():
00291             member = membership.getAuthenticatedMember()
00292             if registration:
00293                 failMessage = registration.testPropertiesValidity(properties, member)
00294                 if failMessage is not None:
00295                     raise BadRequest(failMessage)
00296             member.setMemberProperties(properties)
00297         else:
00298             raise BadRequest('Not logged in.')

Here is the call graph for this function:

def CMFCore.MemberDataTool.MemberData.setSecurityProfile (   self,
  password = None,
  roles = None,
  domains = None 
)
Set the user's basic security profile

Definition at line 356 of file MemberDataTool.py.

00356 
00357     def setSecurityProfile(self, password=None, roles=None, domains=None):
00358         """Set the user's basic security profile"""
00359         u = self.getUser()
00360 
00361         # The Zope User API is stupid, it should check for None.
00362         if roles is None:
00363             roles = list(u.getRoles())
00364             if 'Authenticated' in roles:
00365                 roles.remove('Authenticated')
00366         if domains is None:
00367             domains = u.getDomains()
00368 
00369         u.userFolderEditUser(u.getUserName(), password, roles, domains)

Here is the call graph for this function:


Member Data Documentation

CMFCore.MemberDataTool.MemberData.__implements__ = z2IMemberData [static, private]

Definition at line 245 of file MemberDataTool.py.

Definition at line 250 of file MemberDataTool.py.

tuple CMFCore.MemberDataTool.MemberData.security = ClassSecurityInfo() [static]

Definition at line 247 of file MemberDataTool.py.


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