[Zope] Acquisition problem - please help

Evan Simpson evan@4-am.com
Fri, 17 Dec 1999 12:29:06 -0600


Dave Parker wrote:

> /one
> -methodX
>         /two
>         -propertyA(1)
>         /three
>                 /four
>         /five
>         -propertyA(2)
>
> http://host/one/two/three/four - methodX sees propertyA(1)
> http://host/one/five/three/four - methodX sees propertyA(2)
>
> So the thing that doesn't jibe is that it can't *just* be the physical
> path - were that the case what I'm doing here would not work at all,
> right?

It isn't *just* the physical path, but that does have an effect.  As long as
you proceed from container to contained, acquisition simply looks back up the
path.  The moment you acquire something from above the current container, you
effectively bring in the context of the acquired object.  Let's break it down
using 'of' for acquisition parents, and brackets to indicate that a name
includes its context:

/one -> [one] -> one
/one/two -> [two] -> two of [one]
... and now it gets a little tricky ...
/one/two/three -> [three] of [two] -> (three of [one]) of [two]
/one/two/three/four -> [four] of [two]*
* Not quite accurate, it's really four of ([three] of [two]), but don't worry
about it

Since methodX is a method, it doesn't add any context, so PropertyA is searched
for in [four] of [two], and found in [two].

/one/five -> [five]
/one/five/three -> [three] of [five]
/one/five/three/four -> [four] of [five]

and PropertyA is found in [five].

Now, if 'three' had a 'PropertyA', both of the above would have found that
first in [four] (/one/three/four), so to get the same results you would have to
rearrange your URLs into '/one/three/four/two' -> [two] of [four] and
'/one/three/four/five' -> [five] of [four].

Not to mention, if you replace methodX with DocumentX and try to put a default
'PropertyA' in 'one' then no force in the world can save you, since:

/.../DocumentX -> [DocumentX] of (...) -> (DocumentX of one) of (...)

...and you'll always search 'one' before any other folder.

If you really want a default, you need to put it a folder (such as 'three')
which is *not* in [two] or [five], but *is* in [three], and ensure that 'three'
appears earlier in your URLs than 'two' or 'five'.

Clear? <wink>

Cheers,

Evan @ 4-am