[Zope-CMF] subclassing CMFPlone.MembershipTool

Karl Anderson kra@monkey.org
17 Jul 2002 18:34:51 -0700


This is really a Python question, but I'm wondering how the Plone
people do this.  I'm trying to sublclass Plone's MembershipTool using
the source below.  It overrides creeateMemberarea(), and currently
does exactly what Plone's version does.

When it is called, it gives me an attribute error because
self.__getPUS() is munged to self._MyMemberhipTool__getPUS(), whether
I'm subclassing from CMFDefault or CMFPlone.  That's to be expected,
but how does Plone get away with the same thing?



#from Products.CMFDefault.MembershipTool import MembershipTool
from Products.CMFPlone.MembershipTool import MembershipTool

class MyMembershipTool(MembershipTool):
    """
    """
    meta_type = 'CMF Membership Tool Foo'

    def createMemberarea(self, member_id):
        """
        create a member area with a workflow enabled homepage
        """
        parent=self.aq_inner.aq_parent
        members=getattr(parent, 'Members', None)
    
        if members is not None and not hasattr(members, member_id):
            f_title = "%s's Home" % member_id
            #addPloneFolder(members, id=member_id )
            if members.meta_type=='Plone Folder':
                members.manage_addPloneFolder( member_id, f_title )
            else:
                members.manage_addPortalFolder( member_id, f_title)

            f=getattr(members, member_id)
    
            # Grant ownership to Member
            acl_users = self.__getPUS()
            user = acl_users.getUser(member_id).__of__(acl_users)
            f.changeOwnership(user)
            f.manage_setLocalRoles(member_id, ['Owner'])
    
            # the below skips workflow                          
            Document.addDocument( f
                                , 'index_html'
                                , member_id+"'s Home"
                                , member_id+"'s front page"
                                , "structured-text"
                                , (default_member_content % member_id)
                                )
    
            wf_tool=getToolByName(self, 'portal_workflow')
            homepage=getattr(f, 'index_html')
	    wf_tool.notifyCreated(homepage)
    
            f.index_html._setPortalTypeName( 'Document' )
            # Overcome an apparent catalog bug.
            f.index_html.reindexObject()
            #Add .personal folder for Portraits and Personal content
            f.manage_addPortalFolder(id='.personal', title='Personal Items')

-- 
Karl Anderson      kra@monkey.org           http://www.monkey.org/~kra/