[Zope] Acquisition not working as expected

Dieter Maurer dieter at handshake.de
Thu Mar 2 13:44:40 EST 2006


Roman Klesel wrote at 2006-3-2 08:13 +0100:
> ...
>I can call this method on whatever folder inside the product instance (instance of the base class ZLTMS) I want, it will
>always return the id of the instace of the base class (where the method is defined) and not the id of the object (Folder
>object or File object)

This is how acquistion works (and should work):

  When you acquire a method, the "self" this method is called
  with is usually *NOT* the object acquisition is applied on.

If you think about it, you will recognize that this must be the case:

  For any method "m" of class "C", its first argument *MUST* be
  a "C" instance.

  If you acquire the method "m" starting from "o", then
  "o" may have a completely different class then "m".


In your case, the method "test3" is not defined by "Folder"
but by what you call "your product instance" (still a wrong term!).
Therefore, its "self" is necessarily an instance of "your product"
(I keep your wrong term). And "self.getId()" gives (consequently)
its (and not the Folder's) id.


You cannot do with acquisition what you want to do...

-- 
Dieter


More information about the Zope mailing list