[Zope] Sorting mod.time with dtml-in?

Dieter Maurer dieter@handshake.de
Fri, 4 May 2001 20:32:57 +0200 (CEST)


bak (kedai) writes:
 > >
 > > Assuming version 2.3, try:
 > >
 > > <dtml-in expr="subdir.objectValues()"
 > > sort_expr="bobo_modification_time()">
 > >
 > > since it is a method.
Do not believe this!

The value of the "sort" attribute is a comma separated
sequence of field names. A field name is either the name
of a member or a parameterless function/method (maybe acquired).
The sequence is lexicographically sorted with respect to the
values of these fields.

Thus, you have "sort=bobobase_modification_time".

 > what's the difference between using sort and sort_expr?  the sort=something 
 > has been there since forever :) and i have been using it in my codes.  is it 
 > something bad?
"sort_expr" is nothing bad.

With "sort" your sort specification is constant.
You can say, sort first according to "time" then to "id".
But you cannot say, sort according to the field name currently
held in variable "sort_by". This is necessary for such
nice "sort" features found wide spread: click on a column
head and the content is sorted with respect to this column...
You would use "sort_expr=sort_by" for this.

The value of "sort_expr" must evaluate to a sort specification.
The specification is interpreted in the same way as when
given directly to sort. But it can be computed, it no longer
is constant...

More info

  URL:http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html


Dieter