[Zope] Tuple unpacking in DTML

David Shaw david.shaw@zapmedia.com
Sat, 09 Jun 2001 08:56:26 -0400


> From: "Daniel Fairs" <daniel.fairs@spiderplant.net>
> How do you unpack a tuple in DTML?
> 
> I have a python method getEntries that returns a list of tuples. Each tuple
> is of the form: (doc_text, doc_title, doc_date)
...
> <dtml-in getEntries reverse>
>         <dtml-let expr="sEntry,sTitle,oTime=_.getitem('sequence-item')">

The syntax kinda sucks, but here's how you have to do it:

<dtml-in getEntries reverse>
    <dtml-let data="_.getitem('sequence-item')"
              sEntry="data[0]"
              sTitle="data[1]"
              oTime="data[2]">

        <do some stuff>

    </dtml-let>
</dtml-in>

HTH,

   - David