[Zope] Choice of the sorting key of a dtml-in tag

Jean Lagarde jean.lagarde@eer-rc.com
Fri, 13 Jul 2001 14:30:36 -0700


Benoit,

I was looking at the source code (I'm trying to figure out how to put
multiple keys in sort_expr -- it does not accept a list as I first assumed),
and found that there is also a reverse_expr attribute which will do exactly
what you need.

So you need to use both sort_expr="skey" and reverse_expr="rev" (I think
that rev=='' will not reverse, but if that doesn't work, try setting rev to
None).

Cheers,

Jean

> -----Original Message-----
> From: Benoit DOMINIAK [mailto:koubonline@hotmail.com]
> Sent: Friday, July 13, 2001 07:33
> To: jean.lagarde@eer-rc.com
> Cc: zope@zope.org
> Subject: Re: [Zope] Choice of the sorting key of a dtml-in tag
>
>
> Yes !!!
> That's it !
> But know, how can I include reverse ;-) ?
> I've tryed :
> <a href="<dtml-var URL1>?skey=titre&rev=">Title</a>
> <a href="<dtml-var URL1>?skey=author&rev=">Author</a>
> <a href="<dtml-var URL1>?skey=bobobase_modification_time&rev=
> reverse">Last
> modification</a>
>
> <dtml-if "REQUEST.has_key('skey')">
> <dtml-else>
> <dtml-call "REQUEST.set('skey', 'bobobase_modification_time')">
> <dtml-call "REQUEST.set('rev', ' reverse')">
> </dtml-if>
>
> <dtml-in "objectValues(['article'])" size=3 sort_expr="skey+rev"
> start=query_start>
>
> But it just work with title and author (rev=none) but not with modif_time
> (rev=' reverse').
>
> Can you help me ?
>
> >From: "Jean Lagarde" <jean.lagarde@eer-rc.com>
> >To: <zope@zope.org>
> >Subject: Re: [Zope] Choice of the sorting key of a dtml-in tag
> >Date: Fri, 13 Jul 2001 07:20:31 -0700
> >
> >Hi Benoit,
> >
> >My first answer post!
> >
> >Although I haven't tried that yet, my understanding is that 'sort' only
> >accepts constants, i.e. it will interpret skey as the literal
> 'skey', not
> >as
> >its value. You need to use the undocumented 'sort_expr' instead, i.e.
> >
> ><dtml-in "objectValues(['article'])" size=3 sort_expr="skey"
> >start=query_start>
> >
> >I'm not sure if you can include 'reverse' in skey; you probably have to
> >state
> >that separately in the dtml-in tag.
> >
> >Hope that solves your problem,
> >
> >Do a search on sort_expr on this list for more details.
> >
> >Cheers,
> >
> >Jean
> >
> >On Friday 13 July 2001 15:03, you wrote:
> >
> > > Hi again,
> > >
> > > I'd like to make a page with a list of my Zclass instances and to be
> >able
> >to
> > > sort them by different key. I tryed with this code :
> > >
> > > <dtml-if "REQUEST.has_key('skey')">
> > > <dtml-else>
> > > <dtml-call "REQUEST.set('skey', 'bobobase_modification_time
> reverse')">
> > > </dtml-if>
> > > <dtml-in "objectValues(['article'])" size=3 sort=skey
> start=query_start>
> > >
> > > But it doesn't work : instances are not sorted correctly...
> > >
> > > Any idea ?
> >
> >
> >
> >
> >_______________________________________________
> >Zope maillist  -  Zope@zope.org
> >http://lists.zope.org/mailman/listinfo/zope
> >**   No cross posts or HTML encoding!  **
> >(Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
>
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.