Re: [Zope] Sorting mod.time with dtml-in?
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
Dieter Maurer wrote:
The value of the "sort" attribute is a comma separated sequence of field names.
Is the same true for ZCatalog? If not, can this be used to have the same effect on ZCatalog search results or would the benefits of the lazy results set in a batched search be lost? cheers, Chris
Chris Withers writes:
The value of the "sort" attribute is a comma separated sequence of field names.
Is the same true for ZCatalog? I do not think so.
If not, can this be used to have the same effect on ZCatalog search results or would the benefits of the lazy results set in a batched search be lost? Of course, you can use "in"'s sort attribute to sort a ZCatalog result sequence. And surely, you need to fetch the sequence elements to sort them.
Dieter
Dieter Maurer wrote:
Chris Withers writes:
The value of the "sort" attribute is a comma separated sequence of field names.
Is the same true for ZCatalog? I do not think so.
If not, can this be used to have the same effect on ZCatalog search results or would the benefits of the lazy results set in a batched search be lost? Of course, you can use "in"'s sort attribute to sort a ZCatalog result sequence. And surely, you need to fetch the sequence elements to sort them.
Dieter
You can pass the sort-on or sort_on argument to a ZCatalog to do lazy sorting at query time. You can only sort on indexes however. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
* Dieter Maurer <dieter@handshake.de> [2001-05-04 20:32]:
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.
Well, you _can_ do this only using the "sort" attribute. I think a lot of folks do it the hard way, not the smart way you described, because of page 74 in the Zope Book's PDF file (Chapter 5, the File Library example). Cheers, Nils
* Dieter Maurer <dieter@handshake.de> [2001-05-04 20:32]:
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.
Well, you _can_ do this only using the "sort" attribute. I think a lot of folks do it the hard way, not the smart way you described, because of page 74 in the Zope Book's PDF file (Chapter 5, the File Library example). Cheers, Nils
participants (4)
-
Casey Duncan -
Chris Withers -
Dieter Maurer -
Nils Kassube