[Zope] Zope Object Contexts and Acquisition
Peter Sabaini
sabaini@inode.at
Fri, 1 Mar 2002 12:31:15 +0100 (CET)
does that do what you want to do?
# pyscript listRoot
rootPath = context.rootPath
root = container.restrictedTraverse(rootPath)
objects = root.objectValues(['Folder'])
return objects
where rootPath is a property i've set on my root folder, with a value
of eg. '/site1' or '/'
hth
peter.
On Tue, 26 Feb 2002, Timo A. Hummel wrote:
> > ><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
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>