[Zope] Catalog sort-on parameter

Tres Seaver tseaver@digicool.com
Thu, 16 Nov 2000 20:03:23 -0500


Menard.Jean-Francois@hydro.qc.ca wrote:
> 
> I'm trying to use the 'sort-on' parameter in a Catalog search, and it
> doesn't work.  I use Zope 2.2.2.
> 
> I read in pasts messages that the 'sort-on' feature was broken, is it still?

The parameter to the Catalog's 'searchResults' method is spelled
'sort_on' (it must be a legal Python identifier, because it is
passed only as a keyword parameter).  'sort_on' is an attribute of
the 'dtml-in' tag;  if you let the catalog sort for you, you will
be *much* better off (assuming it has a reasonable index to use,
that is).

Sorting won't work as expected with TextIndexes (but then, what is
"expected" in that case?)

 
> I'm not sure if I use the right syntax so could someone post an sample code
> here please ?

Here is a working snippet from the PTK::

  <dtml-let newsitems="portal_catalog.searchResults( meta_type='News
Item'
                                                   , sort_on='Date'
                                                   ,
sort_order='reverse'
                                                   ,
review_state='published' )">
  <dtml-in newsitems>
    ...
  </dtml-in>

Tres
-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org