[ZPT] reversing a repeat

Richard Jones richard@bizarsoftware.com.au
Sat, 23 Jun 2001 13:48:55 +1000


On Sat, 23 Jun 2001 13:27, Evan Simpson wrote:
> It's a definite shortcoming of tal:repeat, which I encountered yesterday.
> I'm tempted to add a switch to the Iterator class, but it would still be
> awkward to spell.

How about this extension of the repeat syntax:

   tal:repeat="item here/Catalog();
               sort request/sort_attribute;
               direction request/sort_direction"

Where the sort and direction bits are arguments for repeat to pass on to the 
Iterator. Or...

   tal:repeat="item here/Catalog(); sort_func nocall:here/sortFunction"

Or something like that...


>  In the meantime, I advise a quick Script, like this:
> ## Script (Python) "reversed"
> ##parameters=seq
> ##
> rev = list(seq)
> rev.reverse()
> return rev
> ...so that you can write tal:repeat="item python:here.reversed(queryset)".

Or the list() function could be used on the here/Catalog() call to fix the 
hack I posted...


    Richard

-- 
Richard Jones
richard@bizarsoftware.com.au
Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)