Casey Duncan wrote at 2003-12-4 14:08 -0500:
On Wed, 3 Dec 2003 21:20:50 +0100 Dieter Maurer <dieter@handshake.de> wrote:
Holger Schmidt wrote at 2003-12-3 19:28 +0100: [snip]
Is there a chance to get the path to the object?
In Zope3, but (I fear) not in Zope2.
Zope3 abandons acquistion (or more generally: "context wrapper"s) and puts an explicit parent attribute in objects.
If you have control over the objects, you can emulate Zope3 behaviour in some sense. E.g. you can code the path in an attribute of the object (be carefull with copy/move/rename).
You could store the path as an _v_ attribute perhaps when the object is registered. That should alleviate problems with copy/move since _v_ attrs aren't persisted.
I do not think, it will work. As a side effect how acquisition works, the registering objects are unwrapped (if they are persistent objects and they register automatically because they have been modified): Assigning to an object's attribute (or accessing an object's attribute) effectively works on "aq_base". This implies (among others) that the "self" of "__getattr__" and "__setattr__" are unwrapped. It also implies that (automatically) registered objects are unwrapped. -- Dieter