[Zope] Building a list programmatically under DTML

Rik Hoekstra hoekstra@fswrul.fsw.leidenuniv.nl
Tue, 7 Sep 1999 11:24:31 +0200


>
> I don't think you need an EM for that.
>
> Just try
>    <dtml-call "desc.append(_[Category])">
>    <dtml-call "desc_qty.append(qty)">
>
> You don't need the idx var at all this way.
>
> You could also try a dictionary:
>
>   <dtml-call "REQUEST.set('desc', {})">
>    .
>   .
>    .
>   <td>
>     <dtml-var expr="_[Category]">
>     <dtml-if "_[Category][0:2] <> 'No'">
>       <dtml-call "desc[_[Category]] = qty">
>     </dtml-if>
>   </td>
>
> And you can later loop over the keys() or items() methods of the
> dictionary.

To set things straight: dictionaries are not allowed as variables in dtml -
they result in syntax errors. In fact Martijn himself :-\ suggested
alternatives for dictionaries in
http://www.zope.org/pipermail/zope/1999-August/009166.html

Rik