[Zope] I'm blind...

Evan Simpson evan@tokenexchange.com
Wed, 18 Aug 1999 13:23:37 -0500


From: Arnaud Lecat <lecat@hexanet.fr>
> After playing and playing with Zope, I still don't understand what is
> the difference
> between DTML document and DTML method... :( Anyone can tell me clearly ?

There are several subtle differences in behavior, all of which boil down to
one fundamental point:  When rendering, a DTML Document is placed on the
aquisition stack, while a DTML Method is not.  Clear as mud, eh?

Suppose you have a folder 'tryit' which contains Method 'm', Document 'd',
and Folder 'f'.  Folder 'f' contains Document 'show'.  If you ask for
'tryit/f/show', then names are looked up in 'show' first, then 'f', then
'tryit'.  If you ask for 'tryit/d', names are looked up in 'd' first, then
in 'tryit'.  If you ask for 'tryit/m', names are only looked for in 'tryit'!
This is one reason Methods don't have Properties; They would be too hard to
access.

Consider these snippets:
1. <!--#var d-->
2. <!--#with tryit--><!--#var d---><!--#/with-->
3. <!--#with f--><!--#var d--><!--#/with-->
4. <!--#var "tryit.d(this(), REQUEST)"-->

Now, acquisition always allows 'show' to access 'm' and 'd', since to get to
'show' you must pass through 'tryit' via paths like 'tryit/f/show'.  If
'show' contains any of (1) through (4) then 'd' will always search itself
for names first.

Suppose we replace 'd' with 'm' in 1,2,3, and 4, and ask for 'tryit/f/show'.
In no case will 'm' search itself for names. In (1) and (4), 'show' will be
searched first.  In (2), 'tryit' will be searched.  In (3), 'f' will be
searched.

> Second question... how to access a method (or document ?) located in a
folder
> up from actual position ? I'm trying to make a sidebar menu which I could
use
> from anywhere of my site and that should display the subfolder of a
folder...

As long as the thing you want to access is the context built by your URL,
you can just name it directly.  If the URL is 'a/b/c/d', then you can name
any property or method of 'a', 'b', 'c', or 'd' and any object directly
contained by any of them.  Otherwise, just reach back to the highest object
that the accessor and accessee have in common, and move forward from there.

For example, to access 'a/b/s1/s2/doc' from 'a/b/c/d', you could write:
<!--#with s1--><!--#with s2--><!--#var doc--><!--#/with--><!--#/with-->
or just
<!--#with "s1.s2"--><!--#var doc--><!--#/with-->
If 'c' or 'd' might contain an 's1' you don't want, then use:
<!--#with "b.s1.s2"--><!--#var doc--><!--#/with-->

does-this-help-or-confuse;I-can't-tell-ly y'rs
Evan Simpson