[ZPT] tal:repeat and variables
Troy Farrell
troy@entheossoft.com
Thu, 13 Feb 2003 01:11:58 -0600
Clemens Robbenhaar wrote:
> <snip>
>
> I don't think there is a better way. The tal:repeat is just designed in
> a way that all elements in a repeat are rendered nearly independent of
> each other.
>
> Despite it is actually presentation logic and not application logic, I
> would tend to filter the result set through a python script, replacing
> the unwanted entries by empty strings. I did not work with SQL result
> sequences, but I guess one maybe has to make a copy of the result
> sequence, as the original sequence may be immutable.
I'd have to agree: this is a job for a python script. I would make a
dictionary of tuples (or lists) like this:
{'Computers': ('John','Dilvert','Smith')
,'Software': ('Peter','Mary',)
}
<table>
<span tal:omit-tag=""
tal:repeat="k python:data.keys()">
<tr tal:repeat="d data[k]">
<td tal:content="k"
tal:condition="repeat/d/start"/>
<td tal:content="d">
</tr>
</span>
</table>
The code is untested, but I hope that helps you out...
Troy