[Zope] how is a method aquired?

Dylan Reinhardt zope@dylanreinhardt.com
20 May 2003 13:30:06 -0700


On Tue, 2003-05-20 at 12:17, Ulrich Wisser wrote:
> /msg          (prints "msg in root folder")
> /sub1/msg     (prints "msg in sub1 folder")
> /sub2/test    (&dtml-msg;)
> 
> when I access my test method it prints
> "msg in root folder" when I use these URLs
> 
> http://domain/sub2/test
> http://domain/sub1/sub2/test
> 
> why isn't the msg method from sub1 called when using the
> second URL?

Because Acquisition *first* checks if the name it's looking for is in
the containment path before it checks for availability from context.

For what you sketched out, the process would go something like this:

1. The test object is called
2. The test object needs a name called msg
3. Is msg available from test?
4. Attempt to acquire msg by containment
4a. Is msg available from sub2?
4b. Is msg available from root?
5. Attempt to acquire msg from context
5a. Is msg available from sub2?
5b. Is msg available from sub1?
5c. Is msg available from root?

Since it finds msg in step 4b, it never gets to the step where it would
find msg in sub1.  If you want test always to use a particular msg,
there are ways to do that, like:

<dtml-with sub2>
   <dtml-var msg>
</dtml-with>

HTH,

Dylan