[Zope] Access to DTML Document properties

Luciano Ramalho luciano@magnet.com.br
Tue, 09 Mar 1999 22:52:31 -0300


We have been unable to access properties of the new DTML Document objects
in the same way we used to access properties of Folders. 

I don't know whether we are doing something wrong or we found an
inconsistency in the new 1.10 Zope API.

Here is a very simplified test case illustrating the issue.

I have a folder with these contents:

folder1 [Folder]
- broken_html [DTML Document]
- index_html [DTML Document]
- sub-document (The Grand Sub-Document) [DTML Document]
- sub-folder (The Grand Sub-Folder) [Folder]

The source of index_html (which works) is:

<!--#var standard_html_header-->
<h2><!--#var title_or_id--></h2>
<p>Title of sub-item: <!--#var expr="_['sub-folder'].title"--></p>
<p>Author of sub-item: <!--#var expr="_['sub-folder'].author"--></p>
<!--#var standard_html_footer-->

This works as expected. The properties title and author of the sub-folder
are retrieved.

The source of broken_html is exactly the same, except for the sub-document
reference:

<!--#var standard_html_header-->
<h2><!--#var title_or_id--></h2>
<p>Title of sub-item: <!--#var expr="_['sub-document'].title"--></p>
<p>Author of sub-item: <!--#var expr="_['sub-document'].author"--></p>
<!--#var standard_html_footer-->

Viewing this document-method I get a "Zope Unavailable" message with this
traceback:

<!--
 Error type:  
 Error value: 'string' object has no attribute 'title'
 -->
</BODY></HTML>
<!--
Traceback (innermost last):
  File M:\IDG\Zope\lib\python\ZPublisher\Publish.py, line 877, in
publish_module
  File M:\IDG\Zope\lib\python\ZPublisher\Publish.py, line 590, in publish
    (Info: /testes/new_docs_props/broken_html)
  File M:\IDG\Zope\lib\python\OFS\DTMLDocument.py, line 212, in __call__
    (Object: broken_html)
  File M:\IDG\Zope\lib\python\OFS\DTMLDocument.py, line 208, in __call__
    (Object: broken_html)
  File M:\IDG\Zope\lib\python\DocumentTemplate\DT_String.py, line 513, in
__call__
    (Object: broken_html)
  File M:\IDG\Zope\lib\python\DocumentTemplate\DT_Util.py, line 266, in eval
    (Object: _['sub-document'].title)
  File &lt;string&gt;, line 0, in ?
  File M:\IDG\Zope\lib\python\DocumentTemplate\DT_Util.py, line 128, in
careful_getattr
AttributeError: (see above)
-->

So, how do I access properties of sub-documents from a sub-document in the
same folder?

[]s
Luciano Ramalho

--
Not all who wander are lost. [J.R.R.Tolkien]