[ZPT] reversing a repeat
Phil Harris
phil.harris@zope.co.uk
Sat, 23 Jun 2001 01:46:14 +0100
Richard,
Thanks for replying, but I've already tried something along those lines.
I did though try your suggestion, just in case I'd fsck'd something up:
<span tal:define="cat python:here.Catalog()" tal:repeat="item
python:cat.reverse() or cat">
<div class="articleTitle">
<a class="articleLink" href="" tal:attributes="href item/linkUrl"
tal:content="item/Title">link text</a>
<div class="email">
<span tal:replace="here/bobobase_modification_time">timedate
here</span>
(<a href="mailto:" tal:attributes="href python:'mailto' +
item.email" tal:content="item/author">author</a>)
</div>
</div>
<div class="article" tal:content="item/content"> </div>
<br />
</span>
</div>
I get an attribute error on reverse, it seems that the results from the
Catalog don't have either reverse or sort methods.
Thanks anyway.
Phil
phil.harris@zope.co.uk
----- Original Message -----
From: "Richard Jones" <richard@bizarsoftware.com.au>
To: "Phil Harris" <phil.harris@zope.co.uk>; <zpt@zope.org>
Sent: Saturday, June 23, 2001 1:44 AM
Subject: Re: [ZPT] reversing a repeat
> On Sat, 23 Jun 2001 10:23, Phil Harris wrote:
> > Hi all,
> >
> > I have this bit of code:
> >
> > <div metal:fill-slot="main" id="main">
> > <span tal:repeat="item here/Catalog">
> > <div class="articleTitle">
> > <a class="articleLink" href="" tal:attributes="href
item/linkUrl"
> > tal:content="item/Title">link text</a>
> > <div class="email">
> > <span tal:replace="here/bobobase_modification_time">timedate
> > here</span>
> > (<a href="mailto:" tal:attributes="href python:'mailto' +
> > item.email" tal:content="item/author">author</a>)
> > </div>
> > </div>
> > <div class="article" tal:content="item/content"> </div>
> > <br />
> > </span>
> > </div>
> >
> >
> > Which works fine, but I would like to reverse the results from the call
to
> > Catalog.
> >
> > I can't see any way, out of the box, that 'repeat' can reverse the
results.
>
> Try something like:
>
> <span tal:define="res python:['1','2','3','4']"
> tal:repeat="r python:res.reverse() or res"
> tal:content="r">hello, world</span>
>
>
> Richard
>
> --
> Richard Jones
> richard@bizarsoftware.com.au
> Senior Software Developer, Bizar Software (www.bizarsoftware.com.au)
>
> _______________________________________________
> ZPT mailing list
> ZPT@zope.org
> http://lists.zope.org/mailman/listinfo/zpt