[Zope] Can dtml-in iterate over a list of lists?

Dunigan, Craig craig.dunigan@esker.com
Thu, 19 Apr 2001 14:01:12 -0500


I have a Python script called "listArticles" that accepts a sort parameter
called "EWSortOrder," and returns a sorted list of lists.  I would like to
display the list of lists using a DTML method called "ArticleList" that
looks something like this:

<table>
<dtml-in expr="listArticles(EWSortOrder)">
<tr><td class="1">sequence-item[0]</td></tr>
<tr><td class="2">sequence-item[1]</td></tr>
....
</dtml-in>
</table>

where sequence-item is obviously the list in the current iteration, but
clearly Zope isn't recognizing it as a list:

Error Type: KeyError
Error Value: sequence-item[0]

Traceback (innermost last):
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 222, in
publish_module
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 187, in
publish
  File /opt/Zope/ZopeInst/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
    (Object: CatalogAware)
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 171, in
publish
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/mapply.py, line 160, in
mapply
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 112, in
call_object
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/OFS/DTMLMethod.py, line 189, in
__call__
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_String.py, line
538, in __call__
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_In.py, line 711, in
renderwob
    (Object: listArticles(EWSortOrder))
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_Var.py, line 276,
in render
    (Object: sequence-item[0])
KeyError: (see above)

Can I do this, and if so, how can I let dtml-in know to expect a list each
time?  I can't nest dtml-in's because each item in the sub-list is processed
a little differently.

Craig Dunigan
Web Programmer
Esker Software - Extending the Reach of Information
mailto:craig.dunigan@esker.com
Ph. 608.273.6000
Fax 608.273.8227
http://www.esker.com