[Zope] sorting based on object url

Dieter Maurer dieter@handshake.de
Wed, 14 Mar 2001 21:13:15 +0100 (CET)


Parikh, Jay writes:
 > I have a simple ZCatalog that I am trying to sort via the path of the
 > objects.  I have the following so far, and it doesn't seem to work.  
 > 
 > <dtml-in catalog sort="catalog.getpath(data_record_id_)" size=50
 > start=query_start>
With Zope 2.3, you can use "sort=getpath".

I fear, it is much more difficult with older Zope versions.
The "sort_expr" is evaluated just once at the start
of the sort to get a sort specification for the complete
sort. It is not evaluated in the context of each element,
thus, it can not use the elements attributes (such as
"data_record_id_".

You can use a Python Script (or external method)
that returns "catalog.getpath(data_record_id_)" and
use that as sort criterion.



Dieter