Back to index

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

List of all members.

Public Member Functions

def __init__
def pruneMemberDataContents
def purgeMemberDataContents
def updateMemberDataContents
def searchMemberDataContents
def searchFulltextForMembers

Public Attributes

 portraits

Static Public Attributes

 meta_type = ToolNames.MemberDataTool
tuple security = ClassSecurityInfo()
string toolicon = 'skins/plone_images/user.gif'

Private Member Functions

def _getPortrait
def _setPortrait
def _deletePortrait

Static Private Attributes

tuple __implements__ = (PloneBaseTool.__implements__, BaseTool.__implements__, )

Detailed Description

Definition at line 11 of file MemberDataTool.py.


Constructor & Destructor Documentation

Definition at line 20 of file MemberDataTool.py.

00020 
00021     def __init__(self):
00022         BaseTool.__init__(self)
00023         self.portraits=BTreeFolder2(id='portraits')


Member Function Documentation

def CMFPlone.MemberDataTool.MemberDataTool._deletePortrait (   self,
  member_id 
) [private]

Definition at line 34 of file MemberDataTool.py.

00034 
00035     def _deletePortrait(self, member_id):
00036         " remove member_id's portrait "
00037         if self.portraits.has_key(member_id):
00038             self.portraits._delObject(member_id)

def CMFPlone.MemberDataTool.MemberDataTool._getPortrait (   self,
  member_id 
) [private]

Definition at line 24 of file MemberDataTool.py.

00024 
00025     def _getPortrait(self, member_id):
00026         "return member_id's portrait if you can "
00027         return self.portraits.get(member_id, None)

def CMFPlone.MemberDataTool.MemberDataTool._setPortrait (   self,
  portrait,
  member_id 
) [private]

Definition at line 28 of file MemberDataTool.py.

00028 
00029     def _setPortrait(self, portrait, member_id):
00030         " store portrait which must be a raw image in _portrais "
00031         if self.portraits.has_key(member_id):
00032             self.portraits._delObject(member_id)
00033         self.portraits._setObject(id= member_id, object=portrait)

Compare the user IDs stored in the member data
tool with the list in the actual underlying acl_users
and delete anything not in acl_users

Definition at line 40 of file MemberDataTool.py.

00040 
00041     def pruneMemberDataContents(self):
00042         '''
00043         Compare the user IDs stored in the member data
00044         tool with the list in the actual underlying acl_users
00045         and delete anything not in acl_users
00046         '''
00047         BaseTool.pruneMemberDataContents(self)
00048         membertool= getToolByName(self, 'portal_membership')
00049         portraits   = self.portraits
00050         user_list = membertool.listMemberIds()
00051 
00052         for tuple in portraits.items():
00053             member_id = tuple[0]
00054             member_obj  = tuple[1]
00055             if member_id not in user_list:
00056                 self.portraits._delObject(member_id)

Here is the call graph for this function:

Delete ALL MemberData information. This is required for us as we change the
MemberData class.

Definition at line 58 of file MemberDataTool.py.

00058 
00059     def purgeMemberDataContents(self):
00060         '''
00061         Delete ALL MemberData information. This is required for us as we change the
00062         MemberData class.
00063         '''
00064         membertool= getToolByName(self, 'portal_membership')
00065         members   = self._members
00066 
00067         for tuple in members.items():
00068             member_name = tuple[0]
00069             member_obj  = tuple[1]
00070             del members[member_name]
00071 
00072         return "Done."

Here is the call graph for this function:

search for members which do have string 's' in name, email or full name (if defined)

this is mainly used for the localrole form

Definition at line 143 of file MemberDataTool.py.

00143 
00144     def searchFulltextForMembers(self, s):
00145         """search for members which do have string 's' in name, email or full name (if defined)
00146 
00147         this is mainly used for the localrole form
00148         """
00149 
00150         s=s.strip().lower()
00151 
00152         portal = self.portal_url.getPortalObject()
00153         mu = self.portal_membership
00154         is_manager = mu.checkPermission('Manage portal', self)
00155 
00156         res = []
00157         for member in mu.listMembers():
00158             u = member.getUser()
00159             if not (member.listed or is_manager):
00160                 continue
00161             if u.getUserName().lower().find(s) != -1 \
00162                 or member.getProperty('fullname').lower().find(s) != -1 \
00163                 or member.getProperty('email').lower().find(s) != -1:
00164                     res.append(member)
00165         return res
00166 
00167 MemberDataTool.__doc__ = BaseTool.__doc__
00168 
00169 InitializeClass(MemberDataTool)

def CMFPlone.MemberDataTool.MemberDataTool.searchMemberDataContents (   self,
  search_param,
  search_term 
)
Search members.
This is the same as CMFCore except that it doesn't check term case.

Definition at line 111 of file MemberDataTool.py.

00111 
00112     def searchMemberDataContents( self, search_param, search_term ):
00113         """
00114         Search members.
00115         This is the same as CMFCore except that it doesn't check term case.
00116         """
00117         res = []
00118 
00119         search_term = search_term.strip().lower()
00120 
00121         if search_param == 'username':
00122             search_param = 'id'
00123 
00124         mtool   = getToolByName(self, 'portal_membership')
00125 
00126         for member_id in self._members.keys():
00127 
00128             user_wrapper = mtool.getMemberById( member_id )
00129 
00130             if user_wrapper is not None:
00131                 memberProperty = user_wrapper.getProperty
00132                 searched = memberProperty( search_param, None )
00133 
00134                 if searched is not None:
00135                     if searched.strip().lower().find(search_term) != -1:
00136 
00137                         res.append( { 'username': memberProperty( 'id' )
00138                                       , 'email' : memberProperty( 'email', '' )
00139                                       }
00140                                     )
00141         return res

Here is the call graph for this function:

Update former MemberData objects to new MemberData objects

Definition at line 74 of file MemberDataTool.py.

00074 
00075     def updateMemberDataContents(self,):
00076         """Update former MemberData objects to new MemberData objects
00077         """
00078         count = 0
00079         membertool= getToolByName(self, 'portal_membership')
00080         members   = self._members
00081         properties = self.propertyIds()
00082 
00083         # Scan members for old MemberData
00084         for member_name, member_obj in members.items():
00085             values = {}
00086             if getattr(member_obj, "_is_new_kind", None):
00087                 continue        # Do not have to upgrade that object
00088 
00089             # Have to upgrade. Create the values mapping.
00090             for pty_name in properties:
00091                 user_value = getattr( member_obj, pty_name, _marker )
00092                 if user_value <> _marker:
00093                     values[pty_name] = user_value
00094 
00095             # Wrap a new user object of the RIGHT class
00096             u = self.acl_users.getUserById(member_name, None)
00097             if not u:
00098                 continue                # User is not in main acl_users anymore
00099             self.wrapUser(u)
00100 
00101             # Set its properties
00102             mbr = self._members.get(member_name, None)
00103             if not mbr:
00104                 raise RuntimeError, "Error while upgrading user '%s'." % (member_name, )
00105             mbr.setProperties(values, force_local = 1)
00106             count += 1
00107 
00108         return count
00109 

Here is the call graph for this function:


Member Data Documentation

tuple CMFPlone.MemberDataTool.MemberDataTool.__implements__ = (PloneBaseTool.__implements__, BaseTool.__implements__, ) [static, private]

Definition at line 17 of file MemberDataTool.py.

Definition at line 13 of file MemberDataTool.py.

Definition at line 22 of file MemberDataTool.py.

tuple CMFPlone.MemberDataTool.MemberDataTool.security = ClassSecurityInfo() [static]

Definition at line 14 of file MemberDataTool.py.

string CMFPlone.MemberDataTool.MemberDataTool.toolicon = 'skins/plone_images/user.gif' [static]

Definition at line 15 of file MemberDataTool.py.


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