[Zope-CMF] Access to other members properties

Tres Seaver tseaver@zope.com
09 Aug 2002 10:09:40 -0400


On Fri, 2002-08-09 at 07:21, John_Knutson@candle.com wrote:
> OK, I can now set my 'notify' property. Now I need to create a list of the
> email addresses of all of the members that have the 'notify'property set.
> 
> I've tried all sorts of things without success. This, for example returns
> the 'notify' property when 'member' is the logged-on user but returns
> Attribute Error for any other name:
> 
> <dtml-var expr="member.getProperty('notify')">
> 
> I've even tried adding new methods to the Membership and MemberData tools
> without success.
> 
> Can anyone direct me in the right direction?

CMFCore.Membershiptool.MembershipTool has a utility method which might
give you a good start:


    security.declarePrivate( 'searchMemberDataContents' )
    def searchMemberDataContents( self, search_param, search_term ):
        """ Search members """
        res = []

        if search_param == 'username':
            search_param = 'id'

        for user_wrapper in self._members.values():
            searched = getattr( user_wrapper, search_param, None )
            if searched is not None and string.find( searched,
                   search_term ) != -1:
                res.append( { 'username' : getattr( user_wrapper, 'id' )
                            , 'email' : getattr( user_wrapper,
                                                 'email', '' )
                            }
                          )

        return res

While this is hardly as general as it could be, it does sketch out the
access method for searching memberdata.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com