[Zope] Can dtml-in iterate over a list of lists?
Thomas B. Passin
tpassin@mitretek.org
Thu, 19 Apr 2001 16:10:57 -0400
Remember -
1) sequence-item[0] needs to be inside a <dtml-var> tag or some such
2) a compound phrase like a[1] needs to be in quotes, but when it is, it
gets evaluated by Python. In this case, Python tries to subtract "item"
from 'sequence". To defeat this, use the alternative syntax
<dtml-var "_['sequence-item'][0]">
the _['...'] syntax lets you refer to something by its id as a string.
Cheers,
Tom P
Dunigan, Craig asks -
> 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]
>