[Zope-CMF] Re: How-To: Automatically Add Objects at CMF Member Creation
Time
Grégoire Weber
gregoire.weber@switzerland.org
Mon, 20 Aug 2001 15:51:25 +0200
Hi Norman,
> How can we extend this so that we can generate a number of portal types so
> that we still have the index_html file that is being generated from the
> CMFDefault/MembershipTool.py plus say two more documents types for example
> profile_html and complex_html
try (untested):
def createMemberarea(self, member_id):
"""
create a member area
"""
# call original 'createMemberarea' method
MembershipTool.createMemberarea(member_id) # <-----------------
parent = self.aq_inner.aq_parent
members = getattr(parent, 'Members', None)
# etc. (unchanged)
This calls the orginal 'createMembershiparea' method instanating the
'index_html' portal document object before instanating your own objects.
> As from your how-to the CMFDefaultHotfix only creates an image now, and=
the
> index_html is no longer created?!?
That's right, I personaly didn't want to have an index_html in the directory.
> One other thing, if we want the default index_html document to have the=
img
> embeded with the body of the document, on creation. Is this possible.
Have a look to the source of 'createMemberarea()'
in /Products/CMFDefault/MembershipTool.py.
Copy the folling code and embed your image using '<img src="pic.gif" />' in
the 'default_member_content' text definition (untested):
# Create Member's home page.
# default_member_content ought to be configurable per
# instance of MembershipTool.
Document.addDocument( f
, 'index_html'
, member_id+"'s Home"
, member_id+"'s front page"
, "structured-text"
, (default_member_content % id)
)
# give the image the correct portal type
ob = f._getOb( 'org_logo' )
if hasattr(ob, '_setPortalTypeName'):
ob._setPortalTypeName('Document')
# Overcome an apparent catalog bug.
f.index_html.reindexObject()
where 'default_member_content' is a string variable to be defined in the
hotfix file. The original text is:
default_member_content = '''Default page for %s
This is the default document created for you when
you joined this community.
To change the content just select "Edit"
in the Tool Box on the left.
'''
Ok?
Greg
_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org