[Zope-dev] Sorting for zope.app.catalog

Dan Korostelev nadako at gmail.com
Tue Dec 30 08:34:53 EST 2008


Hello!

After some discussion, sorting support for zope.index was added. It's
now in zope.index 3.5.0.

So, the next step is to add sorting/limiting/reversing to
zope.app.catalog. I made a "nadako-sorting" branch of
zope.app.catalog. It modifies the ``searchResults`` method
of the catalog so it makes use of special keyword arguments, passed to
it (i believe that's just like zope 2 catalog works).

The names are:

 * _sort_index - the name of index to sort with
 * _reverse - reverse results
 * _limit - limit result set

I added an underscore to the names to mark them as something special,
not just index names and to avoid conflicting with index names that
applications might use. I think there's no application on earth that
has indexes with the names above, so that's not a problem.

If _sort_index is not specified, catalog just uses list mechanisms to
limit/reverse results. I don't think that makes any sense though.
If _sort_index is specified, all sorting, reversing and limiting
functionality is done by the ``sort`` method of specified index. That
index should provide the new IIndexSort interface, defined by
zope.index.

I would like to merge that code to zope.app.catalog trunk and make a
new feature release, containing this functionality. So I'd like
community to review these changes and comment/object it.

Thanks!

-- 
WBR, Dan Korostelev


More information about the Zope-Dev mailing list