[Zope-CMF] Access to other members properties

John_Knutson@candle.com John_Knutson@candle.com
Tue, 13 Aug 2002 16:58:49 +0100


Thanks Tres. That's what I ended up doing, removing the declarePrivate
altogether. I had another interesting problem because I've got one portal
nested inside another and I wanted to access the memberdata from the
top-level portal down below. I managed to achieve that by calling a python
script that resides at the top level using the container binding.

I need (or at least, I think I need) nested sites because my original site
was DTML-based and I wented to use CMFForum which is ZPT-based and I
couldn't figure a way to do it without changing all of my DTML config to
ZPT. Is there an easy way to do that? Can CFMForum live in a DTM site?

Cheers,
John Knutson
Candle Corporation


                                                                                                           
                    Tres Seaver                                                                            
                    <tseaver@zope        To:     John Knutson/CAM/Candle@Candle                            
                    .com>                cc:     zope-cmf@zope.org                                         
                                         Subject:     Re: [Zope-CMF] Access to other members properties    
                    09/08/2002                                                                             
                    15:09                                                                                  
                                                                                                           
                                                                                                           





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