Back to index

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

List of all members.

Public Member Functions

def __init__
def getMemberDataContents
def searchMemberData
def searchMemberDataContents
def pruneMemberDataContents
def wrapUser
def registerMemberData
def deleteMemberData

Static Public Attributes

string id = 'portal_memberdata'
string meta_type = 'CMF Member Data Tool'
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_overview = DTMLFile( 'explainMemberDataTool', _dtmldir )
tuple manage_showContents = DTMLFile('memberdataContents', _dtmldir )

Private Attributes

 _members

Static Private Attributes

tuple __implements__ = (z2IMemberDataTool, )
tuple _properties = ()

Detailed Description

This tool wraps user objects, making them act as Member objects.

Definition at line 45 of file MemberDataTool.py.


Constructor & Destructor Documentation

Definition at line 77 of file MemberDataTool.py.

00077 
00078     def __init__(self):
00079         self._members = OOBTree()
00080         # Create the default properties.
00081         self._setProperty('email', '', 'string')
00082         self._setProperty('portal_skin', '', 'string')
00083         self._setProperty('listed', '', 'boolean')
00084         self._setProperty('login_time', '2000/01/01', 'date')
00085         self._setProperty('last_login_time', '2000/01/01', 'date')


Member Function Documentation

Delete member data of specified member.

Definition at line 213 of file MemberDataTool.py.

00213 
00214     def deleteMemberData(self, member_id):
00215         """ Delete member data of specified member.
00216         """
00217         members = self._members
00218         if members.has_key(member_id):
00219             del members[member_id]
00220             return 1
00221         else:
00222             return 0
00223 
00224 InitializeClass(MemberDataTool)
00225 registerToolInterface('portal_memberdata', IMemberDataTool)
00226 

Here is the call graph for this function:

Return the number of members stored in the _members
BTree and some other useful info

Definition at line 90 of file MemberDataTool.py.

00090 
00091     def getMemberDataContents(self):
00092         '''
00093         Return the number of members stored in the _members
00094         BTree and some other useful info
00095         '''
00096         # XXX: this method violates the rules for tools/utilities:
00097         # it depends on a non-utility tool
00098         membertool   = getToolByName(self, 'portal_membership')
00099         members      = self._members
00100         user_list    = membertool.listMemberIds()
00101         member_list  = members.keys()
00102         member_count = len(members)
00103         orphan_count = 0
00104 
00105         for member in member_list:
00106             if member not in user_list:
00107                 orphan_count = orphan_count + 1
00108 
00109         return [{ 'member_count' : member_count,
00110                   'orphan_count' : orphan_count }]

Here is the call graph for this function:

Delete data contents of all members not listet in acl_users.

Definition at line 178 of file MemberDataTool.py.

00178 
00179     def pruneMemberDataContents(self):
00180         """ Delete data contents of all members not listet in acl_users.
00181         """
00182         # XXX: this method violates the rules for tools/utilities:
00183         # it depends on a non-utility tool
00184         membertool = getToolByName(self, 'portal_membership')
00185         members = self._members
00186         user_list = membertool.listMemberIds()
00187 
00188         for member_id in list(members.keys()):
00189             if member_id not in user_list:
00190                 del members[member_id]

Here is the call graph for this function:

Add the given member data to the _members btree.

Definition at line 207 of file MemberDataTool.py.

00207 
00208     def registerMemberData(self, m, id):
00209         """ Add the given member data to the _members btree.
00210         """
00211         self._members[id] = aq_base(m)

def CMFCore.MemberDataTool.MemberDataTool.searchMemberData (   self,
  search_param,
  search_term,
  attributes = () 
)
Search members. 

Definition at line 112 of file MemberDataTool.py.

00112 
00113     def searchMemberData(self, search_param, search_term, attributes=()):
00114         """ Search members. """
00115         # XXX: this method violates the rules for tools/utilities:
00116         # it depends on a non-utility tool
00117         res = []
00118 
00119         if not search_param:
00120             return res
00121 
00122         membership = getToolByName(self, 'portal_membership')
00123 
00124         if len(attributes) == 0:
00125             attributes = ('id', 'email')
00126 
00127         if search_param == 'username':
00128             search_param = 'id'
00129 
00130         for user_id in self._members.keys():
00131             u = membership.getMemberById(user_id)
00132 
00133             if u is not None:
00134                 memberProperty = u.getProperty
00135                 searched = memberProperty(search_param, None)
00136 
00137                 if searched is not None and searched.find(search_term) != -1:
00138                     user_data = {}
00139 
00140                     for desired in attributes:
00141                         if desired == 'id':
00142                             user_data['username'] = memberProperty(desired, '')
00143                         else:
00144                             user_data[desired] = memberProperty(desired, '')
00145 
00146                     res.append(user_data)
00147 
00148         return res

Here is the call graph for this function:

def CMFCore.MemberDataTool.MemberDataTool.searchMemberDataContents (   self,
  search_param,
  search_term 
)
Search members. This method will be deprecated soon. 

Definition at line 150 of file MemberDataTool.py.

00150 
00151     def searchMemberDataContents( self, search_param, search_term ):
00152         """ Search members. This method will be deprecated soon. """
00153         # XXX: this method violates the rules for tools/utilities:
00154         # it depends on a non-utility tool
00155         res = []
00156 
00157         if search_param == 'username':
00158             search_param = 'id'
00159 
00160         mtool   = getToolByName(self, 'portal_membership')
00161 
00162         for member_id in self._members.keys():
00163 
00164             user_wrapper = mtool.getMemberById( member_id )
00165 
00166             if user_wrapper is not None:
00167                 memberProperty = user_wrapper.getProperty
00168                 searched = memberProperty( search_param, None )
00169 
00170                 if searched is not None and searched.find(search_term) != -1:
00171 
00172                     res.append( { 'username': memberProperty( 'id' )
00173                                 , 'email' : memberProperty( 'email', '' )
00174                                 }
00175                             )
00176         return res

Here is the call graph for this function:

If possible, returns the Member object that corresponds
to the given User object.

Definition at line 192 of file MemberDataTool.py.

00192 
00193     def wrapUser(self, u):
00194         '''
00195         If possible, returns the Member object that corresponds
00196         to the given User object.
00197         '''
00198         id = u.getId()
00199         members = self._members
00200         if not id in members:
00201             base = aq_base(self)
00202             members[id] = MemberData(base, id)
00203         # Return a wrapper with self as containment and
00204         # the user as context.
00205         return members[id].__of__(self).__of__(u)

Here is the caller graph for this function:


Member Data Documentation

tuple CMFCore.MemberDataTool.MemberDataTool.__implements__ = (z2IMemberDataTool, ) [static, private]

Definition at line 51 of file MemberDataTool.py.

Definition at line 78 of file MemberDataTool.py.

Definition at line 55 of file MemberDataTool.py.

string CMFCore.MemberDataTool.MemberDataTool.id = 'portal_memberdata' [static]

Definition at line 53 of file MemberDataTool.py.

Initial value:
( ({'label': 'Overview',
                       'action': 'manage_overview'},
                      {'label': 'Contents',
                       'action': 'manage_showContents'})
                   + PropertyManager.manage_options
                   + SimpleItem.manage_options
                   )

Definition at line 59 of file MemberDataTool.py.

tuple CMFCore.MemberDataTool.MemberDataTool.manage_overview = DTMLFile( 'explainMemberDataTool', _dtmldir ) [static]

Definition at line 71 of file MemberDataTool.py.

tuple CMFCore.MemberDataTool.MemberDataTool.manage_showContents = DTMLFile('memberdataContents', _dtmldir ) [static]

Definition at line 74 of file MemberDataTool.py.

string CMFCore.MemberDataTool.MemberDataTool.meta_type = 'CMF Member Data Tool' [static]

Definition at line 54 of file MemberDataTool.py.

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

Definition at line 57 of file MemberDataTool.py.


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