[Zope] object.changeOwnership (con't)

Dieter Maurer dieter@handshake.de
Sat, 23 Feb 2002 13:14:19 +0100


Gilles Lenfant writes:
 > I noticed that in lib/python/AccessControl/Owned.py in the Owned class, the "object.changeOwnership(user)"  (line 97) method calls "new = userInfo(user)" (line 234).
 > 
 > Then userInfo() checks "user.aq_inner.aq_parent" (line 240)
 > 
 > The strange thing is that an user object (from any acl_users) has no "aq_inner" nor "aq_parent" attribute. And this raises an AttributeError when trying to change ownership.
 > 
 > Did I take a wrong user object type (acl_users.getUser('foo')) or is this another bug ?
I think, it is a bug (that I fixed in LDAPUserFolder), but one can
have different opinions...

Usually (when you get it from "REQUEST.AUTHENTICATED_USER" or
"getSecurityManager().getUser()",
the user is wrapped in the UserFolder's acquisition context.
The above construct, is an idiom to access the object's container,
i.e. the UserFolder.

The "getUser" method of some UserFolders returns unwrapped objects.
These can not be used with "changeOwnership" (as you found out).
You can wrap them by: "user.__of__(userFolder)". Of course,
this requires non-TTW code.


Dieter