[Zope] Problems calling directory

Dieter Maurer dieter@handshake.de
Fri, 20 Apr 2001 21:15:29 +0200 (CEST)


Adrian Madrid writes:
 > ....
 > This works
 > <dtml-with "Portal.Publications.Review">
 >   <p>This is the <dtml-var document_id> Document 
 >      in the <dtml-var title_and_id> Folder.</p>
 > </dtml-with>
 > 
 > While this code does not work:
 > 
 > <dtml-with "_['Portal.Publications.Review']">
 >   <p>This is the <dtml-var document_id> Document 
 >      in the <dtml-var title_and_id> Folder.</p>
 > </dtml-with>
In the working case, you are in a Python evaluation context.
'.' is there an operator, the attribute lookup operator.

In the failing case, the '.' is not an operator but
behaves identical to the letters.
"_[...]" performs a name lookup for "...".
You look for an object with literal name "Portal.Publications.Review".
There is not such object, only one with name "Portal"
which has an attribute with name "Publications" ....

"restrictedTraverse" is your friend:
Try:

	<dtml-with "restrictedTraverse(_.string.split(location,'.'))">
	....


Dieter