[Zope] Access to DTML Document properties

Amos Latteier amos@aracnet.com
Tue, 09 Mar 1999 22:00:04 -0800


At 01:45 AM 3/10/99 -0300, Luciano Ramalho wrote:

><!--#var expr="_['sub-document'].author"-->
>
>I wrote this, and it worked fine:
>
><!--#var expr="_.getitem('sub-document').author"-->
>
>I found a way, but I don't understand why the first syntax worked fine with
>Folders and fails with DTML Documents. If anyone would like to clarify the
>semantic difference between _['sub-document'] and
>_.getitem('sub-document'), I would be even happier.

The answer is in both the ZDP's FAQ and the DTML Manager's Guide. 

_['foo'] "renders" foo according to DTML rules. This process mostly
consists of calling DTML and other callable objects.

_.getitem('foo') simply returns foo as found in the DTML namespace.

The reason you were having problems is that _['sub-document'] renders the
document to a string. Naturally strings don't have properties. Hence the
error you got from Zope, "'string' object has no attribute 'title'".

Make sense?

-Amos