[Zope-CMF] Changing ownership / creator of a CMF document

robert rottermann robert at redcor.ch
Fri Jun 11 00:55:43 EDT 2004


Kari-Hans Kommonen wrote:

> How should one change the ownership of a CMF document, or 
> alternatively, create a CMF document for some other user?
>
> We receive mails with MailBoxer and want the "mail_handler" to create 
> CMF documents from the mails, so the script is run by "Anonymous user".
>
> What is not clear to me is what actually determines the ownership of a 
> document, and what are all the things one needs to change, and what 
> conditions need to be fulfilled in order to be able to do it, and have 
> as the outcome a CMF document that is in all respects similar to one 
> that the user creates herself on the site.
>
> TIA, kari-hans kommonen
>
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF at zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
>
> See http://collector.zope.org/CMF for bug reports and feature requests
>
>
There are two types of ownerships
- the user who created the object.
    It limits the maximum rigths the object can muster when it is 
executed (hence it's name)
    It can be changed with a method as follows
- a user that has assigned the role owner
    Such a user can assume owner rights when dealing with the object

So what you need to do, is create an external method that sports an 
method like the one that follows.
This external method you call from a python script with the appropriate 
parameters.
That this script is allowed to do its duty, it must have assigned a 
proxy role of admin. you can do so clicking on the scripts tab proxy.

Robert


   
    def changeOwnershipOf(self, object, owner, recursive=0):
        """ changes the ownership of an object """
        #membership=getToolByName(self, 'portal_membership')
        #if owner not in membership.listMemberIds():
        #    raise KeyError, 'Only users in this site can be made owners.'
        acl_users=getattr(self, 'acl_users')
        user = acl_users.getUser(owner)
        if user is not None:
            user= user.__of__(acl_users)
        else:
            from AccessControl import getSecurityManager
            user= getSecurityManager().getUser()

        object.changeOwnership(user, recursive)




More information about the Zope-CMF mailing list