[Zope] Zope Object Contexts and Acquisition

Timo A. Hummel timo.hummel@gmx.net
Tue, 26 Feb 2002 21:28:48 +0100


> ><dtml-in expr="getPhysicalRoot().objectValues(['Folder'])">
> > <some output code>
> ></dtml-in>

When you call the code above in a DTML-Method in your root folder,
it lists all the directories in the root. So far so good. Let's say
you want to restructure your zope project and move everything from
the root into /site1, so you will have these results:

/site1/theobjectValuesDTMLMethod
/site1/folder1
/site1/folder2

So if you use the code above, it will still list the folders of /
and not of /site1. The function objectValues always operates
*relative* to from where it was called (so it is the lowest namespace.
e.g. if you remove the getPhysicalRoot() in the example above, it would
list all folders of /site1/folder1 if /site1/folder1/index_html calls 
theobjectValuesDTMLMethod) and not relative to the object it is actually
called. It would be no difference if the code above is in

/site1/theobjectValuesDTMLMethod

or in

/site1/folder1/index_html

since acquisition does that. The most simple example: Just think of the
whole example as a unix filesystem and the dtml-in stuff just as regular
includes. The "include" /site1/theobjectValuesDTMLMethod would list the
contents of /site1 and not of /site1/folder1, altough
/site1/theobjectValuesDTMLMethod was called from
/site1/folder1/index_html.
In Zope, /site1/theobjectValuesDTMLMethod lists the contents of
/site1/folder1.

Got the point? :)

Best regards
Timo