quick search:

Change Objects Ownership

Submitted by: runyaga
Last Edited: 2001-09-16

Category: Python(External Method)

Average rating is: 4.0 out of 5 (1 ratings)

This recipe allows you to change the ownership of a object through-the-web. since Owned.changeOwnership located in lib/python/AccessControl/Owned.py and is not setup for Through-The-Web callable. we need to explicit set a External Method that allows us to call this functionality through the web.

Source (Text):
#create a file, custom_zmgmt.py in you /Extensions folder on filesystem 

def custom_changeOwnership(self, username, obj):
    """ explicitly setup changeOwnership for TTW """
    acl_users = getattr(self, 'acl_users')    #UserFolder source
    user = acl_users.getUser(username).__of__(acl_users)

#create a External Method in ZOPE called customChangeOwnership
#module name: custom_zmgmt.py
#function name: custom_changeOwnership

#in DTML you can call this by <dtml-call "customChangeOwnership(this(), 'runyaga', this().index_html)">
#in Script (Python) you can simply call it by context.customChangeOwnership('username', context.index_html)

in ZOPE if something is not accessible through-the-web, its a security
feature, it allows you to explicit open up (restricted) that function to through-the-
web coding (Scripts, and DTML) via External Methods (which are competely

we have a External Method that calls into our External Method sitting on the filesystem
which given a username and a object reference will call the changeOwnership method (which
is restricted) on the object passed into this function.

the user object is gotten using some acquistion voodoo, getting the user in the context of the
acl_users folder (if I understand that right). basically wraps the user object you get from the
acl_user folder in the acl_users container. if you dont wrap the user in the UserFolder container
changeOwnership will not work.


Acquistion Algebra:


No Comments