Re: [Zope] Access to DTML Document properties
At 22:31 09/03/99 -0500, Pavlos Christoforou wrote:
You can use the PARENTS variable.
so if you have a folder which contains two DTML Documents A and B then you can access B's properties from A by: <!--# var "PARENTS[0].B.name"--> PARENTS[1] will return the folder or containing object one level up and PARENTS[-1] will return the top most Folder.
Thanks for your help, Pavlos. I found another way. Instead of writing: <!--#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. By the way, Pavlo's site http://www.gaaros.com:9673/ is useful! []s Luciano
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
participants (2)
-
Amos Latteier -
Luciano Ramalho