aq_inner and acquisition by containment only
Hi list, while solving a somewhat intricate acquisition problem, I came discovered, that the statement, that aq_inner will return an object wrapped by containment only seems to be incorrect. Here is the simplified scenario to show this: Let a and c be attributes of x, let b be an attribute of a. Then x.a.c.a.b is the acquisition tree (as shown in Zope 2.7.0 using a little tool akin showaq) O-[b] | O-O-[a] | | | [x] | O-O-[c] | | | [x] | O-[a] | [x] (self goes to the right, parent down). The important thing is, that aq_inner of this is the same tree. I would have expexted to get the reduced tree O-[b] | O-[a] | [x] but looking at the first tree, it is obvious, why this is not the case. The Documentation says, that ( X o Y ) o ( Y o Z ) is simplified to X o ( Y o Z ). While working out the expression, I could find, that this simplification will close to the end simplify the b o ( a o x ) subtree away, since the next expression starts with ( a o x ). This leaves me a little bit uneasy: when searching x.a.c.a.b.aq_inner, c will be searched even though it is *not* in the containment path of b ! I would very much like a comment on this ... Is this known behavior? Should I have expected this? Stefan. -- -- *DON'T* TRY TO REACH ME DIRECTLY AT ABOVE EMAIL ADDRESS. Any reply -- received off-list at that address will be *silently* and -- *unconditionally* dropped. You can attribute this inconvenience to -- the proliferation of spammers on the Internet. I hope, you can -- understand my position and accept my counter measures.
Stefan Bund wrote at 2004-5-11 18:07 +0200:
while solving a somewhat intricate acquisition problem, I came discovered, that the statement, that aq_inner will return an object wrapped by containment only seems to be incorrect. Here is the simplified scenario to show this:
Let a and c be attributes of x, let b be an attribute of a. Then x.a.c.a.b is the acquisition tree (as shown in Zope 2.7.0 using a little tool akin showaq)
O-[b] | O-O-[a] | | | [x] ... (self goes to the right, parent down). The important thing is, that aq_inner of this is the same tree.
Sure, because "aq_self" ("b") is not a wrapper. This is the criterion for an "aq_inner" object. For 0-0-[a] | [x] aq_inner would give you 0-[a] | [x] as in this case, "self" is still a wrapper. -- Dieter
Dieter Maurer <dieter@handshake.de> writes:
Sure, because "aq_self" ("b") is not a wrapper. This is the criterion for an "aq_inner" object.
I know. At least, I think, I understand your statement. I know, that aq_inner is the wrapper directly above aq_base, or in other words the last wrapper found following the aq_self links of the tree. My problem is, *why* is aq_self not a wrapper? I know, how this happens, I can reproduce it using the acquisition algebra and the simplification rule, but that's my point: aq_inner does *not* always produce an object wrapped by containment *only* which I always thought to be the case. Thats at least, how it is documented. Citing from the Zope Developer's Guide (http://zope.org/Documentation/Books/ZDG/current/Acquisition.stx): You can use the special method aq_inner to access an object wrapped only by containment. What I tried to make clear in my post was, that *before* graphing the acquisition tree, I would have expected aq_inner to return the simple tree 'b o ( a o x )' (which would be acquisition by containment only). After I saw the tree, it was clear, why this is not the case. What bothers me is, that the full acquisition chain of 'x.a.c.a.b.aq_inner' includes 'c' which is *not* in b's containment context (is there an 'official' name for the list of *all* objects visited during an acquisition lookup as aq_chain is only the parent chain ... I always call this concept aq_order). I hope, my question/problem is clear now? -- -- *DON'T* TRY TO REACH ME DIRECTLY AT ABOVE EMAIL ADDRESS. Any reply -- received off-list at that address will be *silently* and -- *unconditionally* dropped. You can attribute this inconvenience to -- the proliferation of spammers on the Internet. I hope, you can -- understand my position and accept my counter measures.
Stefan Bund wrote at 2004-5-12 23:31 +0200:
... Thats at least, how it is documented. Citing from the Zope Developer's Guide (http://zope.org/Documentation/Books/ZDG/current/Acquisition.stx):
You can use the special method aq_inner to access an object wrapped only by containment.
When one knows what "aq_inner" does, one can make some sense of this sentence: "aq_inner" is wrapped only be containment because its "aq_self" is not a wrapper; thus, everything left is "aq_parent". Whatever: I have the feeling, that "aq_inner" has only one use case: in the idiom "aq_inner.aq_parent" gives it the object's container. -- Dieter
participants (2)
-
Dieter Maurer -
Stefan Bund