[Zope-CMF] how to modify the add user method?

Dan L. Pierson dan@control.com
Thu, 02 Aug 2001 10:33:06 -0400


Interesting!  I was going to claim that you couldn't set up the ownership
correctly from a script, but your local roles setting may be sufficient.

I still prefer calling this from afterAdd because that catches all possible
member additions instead of just ones that came via register.dtml.  Call
me paranoid if you want :-)

--On Thursday, August 02, 2001 12:21:42 AM -0400 marc lindahl 
<marc@bowery.com> wrote:

> 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.object
> Ids ())
> 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()`
>
>> From: <josh@pdxbands.com>
>> Date: Wed, 1 Aug 2001 19:59:04 -0700
>> To: <dan@control.com>
>> Cc: <zope-cmf@zope.org>
>> Subject: Re: [Zope-CMF] how to modify the add user method?
>>
>> Dan,
>>
>> This would be a great idea.  That is, add in a module or class I can
>> modify to customize the ending effects.  I think the afteradd is a great
>> way to achieve this as I would like to add a default image and folder to
>> the users home directory that will have them as the owner.  I believe
>> that will happen if I make the call to create an object in the afteradd.
>> Is that correct?
>>
>> Does your code that you have in the afteradd achieve this?  If so could
>> you give me a sample as I'm new to python and Zope.
>>
>> Thanks.
>>
>> Josh
>>
>>
>> Message: 4
>> Date: Wed, 01 Aug 2001 11:19:10 -0400
>> From: "Dan L. Pierson" <dan@control.com>
>> To: "zope-cmf@zope.org" <zope-cmf@zope.org>
>> Subject: Re: [Zope-CMF] how to modify the add user method?
>>
>>
>>
>> --On Wednesday, August 01, 2001 07:56:59 AM -0400 Jens Vagelpohl
>> <jens@zope.com> wrote:
>>
>>> - create your own Membership Tool by subclassing from
>>> CMFDefault/MembershipTool.py - implement addMember in your new
>>> membership tool class with all the modifications you want - replace the
>>> default membership tool in the CMF with your own
>>>
>>> that's the "clean and correct" way of doing it. for a code example look
>>> at these files:
>>>
>>> http://cvs.dataflake.org:8080/CMFLDAP/
>>
>> There are two other hooks that may make this easier and, IMHO, just as
>> clean and correct:
>>
>> 1. If all you need to add is additional member properties, the standard
>> addMember processing calls member.setMemberProperties with *all* the
>> properties from the registration form.  The default MemberDataTool turns
>> this into a call on MemberData.setMemberProperties (via a path I don't
>> remember) which filters them to the properties declared in the
>> MemberDataTool.
>>
>> This means that if you are using the default membership support you can
>> define additional member properties by adding them to portal_memberdata's
>> Properties tab and the registration form.
>>
>> If you are not using the default membership support you can make your
>> member object (e.g. ZClass) implement setMemberProperties (this is what
>> we do for LoginManager based members).
>>
>> 2. The last thing RegistrationTool.addMember does is call
>> RegistrationTool.afterAdd.  This means that you can subclass
>> CMFCore.RegistrationTool and define your own afterAdd method.
>> We have one which simply calls a PythonScript skin method named
>> new_member_actions to do any additional member processing.
>> IMHO, this would be a good standard feature for a future CMF.
>>
>>>
>>> jens
>>>
>>> On Wednesday, August 1, 2001, at 04:44 , <josh@pdxbands.com> wrote:
>>>
>>>> Looking for a way to modify the add user call. I would like to be able
>>>> to  do
>>>> some additional features at the time a user is created.
>>>>
>>>> Which file do I need to modify?  Or, can I just put an external method
>>>> call
>>>> when a user is created?
>>>>
>>>> Thanks.
>>>>
>>>> Josh
>>>
>>> _______________________________________________
>>> Zope-CMF maillist  -  Zope-CMF@zope.org
>>> http://lists.zope.org/mailman/listinfo/zope-cmf
>>>
>>> See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
>>> requests
>>>
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Zope-CMF maillist  -  Zope-CMF@zope.org
>> http://lists.zope.org/mailman/listinfo/zope-cmf
>>
>> See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
>> requests
>
>
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cmf
>
> See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
> requests
>