[ZPT] reversing a repeat

Evan Simpson evan@digicool.com
Fri, 22 Jun 2001 23:27:49 -0400


From: "Phil Harris" <phil.harris@zope.co.uk>
> I can't see any way, out of the box, that 'repeat' can reverse the
results.

Ah, yes, this :-(

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.  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)".
Cheers,
Evan @ digicool