[Zope-CMF] Re: How-To: Automatically Add Objects at CMF Member Creation Time
josh@pdxbands.com
josh@pdxbands.com
Tue, 21 Aug 2001 21:15:09 -0700
Greg,
I have been trying to get this to work correctly. I have been having
trouble getting it called. I think I don't quite understand how to get a
method called in the afterAdd method. I thought I could just put some cod=
e
there and it would always run for me. Evidently this is not the case.
What I would really like to achieve with this is to have it run when eve=
r a
user is created. More so, it would go through a directory that is readil=
y
available to an administrator who could add items to the list he would li=
ke
to see populate at creation. This would include/exclude things like:
index_html
image
document
or any other valid object type. Then he could then decide which items th=
e
user could or could not modify.
Next I would also like to see in this directory a default user. This use=
r
object would be special in that you could modify this object and it would=
be
template for all users create afterwards. The advantage here is that I
could add an attribute to all newly created users of the name email. The=
n I
could populate that attribute when I create the user or have the user mod=
ify
it. This would allow for me to have it go with the user. Currently I do=
n't
see how I would achieve this. Ideas?
This is how I envision how it would work. I'm trying to design it so tha=
t
anyone(admin level) could modify one directory and that would change all =
new
users. This person would then know which objects to expect to be present.
Any suggestions welcomed.
Josh
-----Original Message-----
From: Gr=E9goire Weber [mailto:gregoire.weber@switzerland.org]
Sent: Tuesday, August 21, 2001 2:07 AM
To: josh@pdxbands.com
Cc: zope-cmf@zope.org; Norman Khine
Subject: RE: [Zope-CMF] Re: How-To: Automatically Add Objects at CMF
Member Creation Time
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 th=
e
new
> script. If that was achieved then all the objects in the directory wou=
ld
> then automatically populate into the users home directory. You could t=
hen
> 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 se=
ems
> like a logical solution for many people. I relate the creation of a us=
er
> 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 ye=
t.
> But basically, in register.dtml, called this script
> (createUserDefaults.pys), which I'll put below. Modified registered.dt=
ml
> 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 t=
he
> wrong place...):
>
> #copy stuff from user_defaults to user folder, build default mypic imag=
e
> #depends on folder user_defaults with everything there copied
> #and an image user_default_mypic both in the same folder as this script
> #
> uf =3D 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 =3D
>
container.user_defaults.manage_copyObjects(container.user_defaults.object=
Ids
> ())
> uf.manage_pasteObjects(obs)
>
> #uf.mypic.manage_setLocalRoles(username, ['Owner'])
>
> #change this one back, since we're operating in a known, limited situat=
ion
> 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=E9goire Weber
Rigistr. 31
CH-8006 Z=FCrich
Switzerland
phone: +41-(0)1-361 66 11
mobile: +41-(0)79-44 11 457
mailto:gregoire.weber@switzerland.org