[Zope-dev] Sorting for zope.index
Dieter Maurer
dieter at handshake.de
Tue Jan 6 12:00:06 EST 2009
Dan Korostelev wrote at 2008-12-27 17:10 +0300:
>I made a "nadako-sorting" branch of zope.index to add sorting support
>for zope indexes. I defined a new IIndexSort interface that specifies
>a "sort" method that takes document ids and returns an iterable of
>those ids, sorted by indexed value. It supports optional "limit" and
>"reverse" arguments. It also raises KeyError if you pass a docid that
>is not indexed by this index.
A better behaviour might be to sort them at the bottom or let the behaviour
be controlled by an additional (optional) parameter.
Options are:
your solution (raise an exception)
silently ignore objects not indexed (how the Zope "ZCatalog" works)
sort at the bottom.
Further potential interest: Often you want nested sorting: sort according
to one index; for documents not distinguished by this index, sort
on the next level by another index and so on.
To implement this, the index must not only sort the documents but
also indicate which documents it could not distinguish (by e.g.
returning a generator or sequences).
--
Dieter
More information about the Zope-Dev
mailing list