[Zope-CMF] Re: How-To: Automatically Add Objects at CMF Member Creation Time

Grégoire Weber gregoire.weber@switzerland.org
Tue, 21 Aug 2001 11:07:22 +0200


Hi Josh,

I wasn't reading the list the last two (three?) weeks so I missed this ... :-(

Thanks for mentioning that! Did you implement this in your Portal or
is it just a code snipped waiting to be inserted at the correct place?

I agree with you that something like this should be in the core. I made 
this hotfix product because my implementation has only prototype state
(forthe moment) and I didn't want to invest too much time in a much 
cleaner solution.

For the moment I do not have the resources to do the thing the right way,
so proposing a change to the CMFDefault code base.

Greg

At 20:37 20.08.01 -0700, you wrote:
> Greg/Norman,
> 
> 	I have been following this and am interested in achieving the same
> solution.  Earlier I ask this same question a while back and received a=
 good
> solution from another user(Marc and Dan).  Below is the last email I
> received with some sample code.  I have yet to figure out the last part of
> this as I can not seem to understand how to get the Afteradd to call the=
 new
> script.  If that was achieved then all the objects in the directory would
> then automatically populate into the users home directory.  You could then
> make a template area and when you want to add a new default file for a=
 user
> you just have to add it to the directory and presto it is added when a=
 user
> is created.  It seems to me as an easier solution.
> 
> 	Would either you or anyone else know how I call the script from
> registertool.afteradd?
> 
> Thanks.  I would really like to see this added to the CMF core as it seems
> like a logical solution for many people.  I relate the creation of a user
> similar to the creation of a user on a system.  In unix you have a skel=
 dir
> that includes all the default files to be created when a new user is=
 added.
> Makes sense and makes the default user customizable very easily.
> 
> Josh
> 
> Code>>>>
> 
> 
> 
> Message: 5
> Date: Thu, 02 Aug 2001 00:21:42 -0400
> Subject: Re: [Zope-CMF] how to modify the add user method?
> From: marc lindahl <marc@bowery.com>
> To: <zope-cmf@zope.org>
> 
> I did this, and was going to put together a how-to, haven't had time yet.
> But basically, in register.dtml, called this script
> (createUserDefaults.pys), which I'll put below.  Modified registered.dtml
> also, so that I could print a result string from the function (optional
> geekiness).  Also, the .pys had to have a proxy role of owner in order to
> work.  Here's the pythonscript (the lines will probably be wrapped in the
> wrong place...):
> 
> #copy stuff from user_defaults to user folder, build default mypic image
> #depends on folder user_defaults with everything there copied
> #and an image user_default_mypic both in the same folder as this script
> #
> uf = container.portal_membership.getHomeFolder(username)
> 
> uf.manage_permission('Add Documents, Images, and Files', ['Anonymous',
> 'Member', 'Owner','Manager','Reviewer'], 1)
> uf.manage_permission('Add portal content', ['Anonymous', 'Member',
> 'Owner','Manager','Reviewer'], 1)
> 
> obs =
>=
 container.user_defaults.manage_copyObjects(container.user_defaults.objectIds
> ())
> uf.manage_pasteObjects(obs)
> 
> #uf.mypic.manage_setLocalRoles(username, ['Owner'])
> 
> #change this one back, since we're operating in a known, limited situation
> uf.manage_permission('Add Documents, Images, and Files', [], 1)
> uf.manage_permission('Add portal content', [], 1)
> 
> return 'Set up ' + `uf.getId()` +' with default content '+
> `container.user_defaults.objectIds()`

_____________________________________
Grégoire Weber
Rigistr. 31
CH-8006 Zürich
Switzerland
phone:  +41-(0)1-361 66 11
mobile: +41-(0)79-44 11 457
mailto:gregoire.weber@switzerland.org