[Zope] "Acquisition Algebra"; interaction of containment and acquisition is confusing

Dieter Maurer dieter@handshake.de
Fri, 26 Jan 2001 20:31:24 +0100 (CET)


Fred Yankowski writes:
 > ....
 > <http://www.digicool.com/releases/ExtensionClass/Acquisition.html>?
 > I think I understand how the various "complex expressions" relate to
 > the equivalent expression in terms of the '__of__' operator, except
 > for the very last case, "a.b.c.x".  I just can't follow why the
 > equivalent expression isn't
 > 
 > 	x.__of__(a).__of__(c.__of__(b.__of__(a)))
 > 
 > rather than the more complex answer given:
 > 
 > 	x.__of__(a).__of__(b.__of__(a)).__of__(c.__of__(b.__of__(a)))
Acquisition wrappers are ExtensionClass instances with an "__of__"
method.

Whenever, you look up an attribute in an ExtensionClass instance, "i",
and the directly looked up object, "o", (!) has an "__of__" method,
the result is not "o" but "o.__of__(i)".

In your example, "x" is looked up in
"c.__of__(b.__of__(a))". If we assume, that "x"
has a "__of__" method, the result will be:

    "x1.__of__(c.__of__(b.__of__(a))"

with "x1" the result of directly looking up "x" in "c.__of__(b.__of__(a))".

"x" is first looked up in "c". As it is not found there,
it is looked up in "b.__of__(a)". Thus, we have

   "x1=(b.__of__(a)).x"

As "b.__of__(a)" is an ExtensionClass instance (and we assumed "x" has an
"__of__" method). The result will be

   "x2.__of__(b.__of__(a))"

with "x2" the result of directly looking up "x" in "b.__of__(a)".

"x" is first looked up in "b". As it is not found there,
it is looked up in "a". Thus, we have

   "x2= a.x"

If "a" is an ExtensionClass instance, then "a.x" is "x.__of__(a)".


Put things together and you will get the complex result.


Dieter