Using DTML methods to provide HTML
In a DTML document called "authors" I have this situation: <!--#var "sixfield_page(title='Authors and their works', body=authors_body())"--> six_fieldpage is a DTML method which uses two parameters, title and body and returns an entire HTML page. authors_body is a DTML method in the same folder and looks like this: <!--#in get_all_authors--> <!--#var "sixfield_textblock(title=last_name + ', ' + first_name, body=rid)"--> <!--#/in--> When trying to look at authors, I get the following error: Error Type: KeyError Error Value: get_all_authors <!-- Traceback (innermost last): File /home/quest/dls/Zope-2.0.0a3-src/lib/python/ZPublisher/Publish.py, line 256, in publish_module File /home/quest/dls/Zope-2.0.0a3-src/lib/python/ZPublisher/Publish.py, line 161, in publish File /home/quest/dls/Zope-2.0.0a3-src/lib/python/ZPublisher/mapply.py, line 154, in mapply (Object: authors) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/ZPublisher/Publish.py, line 98, in call_object (Object: authors) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/OFS/DTMLDocument.py, line 181, in __call__ (Object: authors) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/OFS/DTMLDocument.py, line 177, in __call__ (Object: authors) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/DocumentTemplate/DT_String.py, line 514, in __call__ (Object: authors) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/DocumentTemplate/DT_With.py, line 133, in render (Object: _.namespace(title='Authors and their works', body=authors_body())) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/DocumentTemplate/DT_Util.py, line 315, in eval (Object: _.namespace(title='Authors and their works', body=authors_body())) File <string>, line 0, in ? File /home/quest/dls/Zope-2.0.0a3-src/lib/python/OFS/DTMLMethod.py, line 152, in __call__ (Object: authors_body) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/DocumentTemplate/DT_String.py, line 514, in __call__ (Object: authors_body) File /home/quest/dls/Zope-2.0.0a3-src/lib/python/DocumentTemplate/DT_In.py, line 628, in renderwob (Object: get_all_authors) KeyError: (see above) --> In Zope/manage things looks like this (to convince you, I have not misspelled anything): / /reviews authors (Authors and their Work) authors_body (Build author list) authors_body_titles (Build list of all titles by one author) get_all_authors (Retr list of all authors) get_titles_by_author (Retr all titles by one author) index_html (Test) reviews_db_connection (Da DB Connection) sixfield_menu (Sixfield style menu) sixfield_page (Sixfield style Page) sixfield_textblock (Sixfield style Textblock) If I understand the error correctly, authors_body is not 'acquired' in the usual zope sense, but rather executed in a more traditional Python context. This raises two questions: 1) How do I make this work? 2) Is this the right way to do things or am I abusing the Zope design? Anders "Quest" Qvist NetGuide Scandinavia -- Why suffer scarcity? Look for the Open Source and enter a world of plenty!
At 01:00 PM 7/11/99 +0200, Anders Qvist wrote:
In a DTML document called "authors" I have this situation:
<!--#var "sixfield_page(title='Authors and their works', body=authors_body())"-->
six_fieldpage is a DTML method which uses two parameters, title and body and returns an entire HTML page. authors_body is a DTML method in the same folder and looks like this:
Change your call to: <!--#var "sixfield_page(_.None,_,title='Authors and their works', body=authors_body())"--> When you call a DTML method in an expression from DTML, you must pass "_.None,_" as the first two parameters if you want the current namespace to pass through. Otherwise, sixfield_page will not have access to any variables other than 'title' and 'body', period. I believe there's some more detail on how this works in the DTML reference manual.
participants (2)
-
Anders Qvist -
Phillip J. Eby