[Zope] problem with manage_permission

Dieter Maurer dieter@handshake.de
Wed, 26 Jul 2000 21:39:29 +0200 (CEST)


Jerome Alet writes:
 > self.manage_permission(permission_to_manage = 
 >   "Access contents information" , roles = [ 'Manager', 'admin' ]) 
 > ..., but the manage_permission
 > call gives me the following traceback: 
 > 
 > Error Type: AttributeError
 > Error Value: aq_acquire
 > 
 > Traceback (innermost last):
 >   ....
 >   File /usr/local/zope/lib/python/OFS/ObjectManager.py, line 173, in
 > _subobject_permissions
 > AttributeError: (see above)
 > 
 > Surprisingly, if I delete the manage_permission line, restart Zope, re-add
 > an instance of MyClass (it works), then try to manually modify the
 > permissions using the MyClass instance's security tab, then it works
 > flawlessly. 
Inside the constructor code (i.e. inside "__init__"),
objects do not yet have an acquisition context; they
are not yet acquisition wrapped.

This means, they do not yet have any of the acquisition attributes:
aq_acquire, aq_base, aq_self, aq_parent, aq_inner.

When they are later accessed, they are not returned themselves.
Rather, an acquisition wrapped version of the object
is returned. The wrapper provides the attributes above.

"manage_permissions" obviously requires obviously requires its
"self" to be a wrapped object.

If you have access to the correct acquisiton context (i.e.
the folder, where you will instantiate the instance), you
can wrap the object yourself:

	self.__of__(context).manage_permissions(....)

Or you must postpone the "manage_permissions", until
you can reaccess the object in the correct context.


Dieter