[ZODB-Dev] Sorting IOBtree items
Thomas Güttler
hv at tbz-pariv.de
Wed Apr 13 06:57:41 EDT 2005
Am Mittwoch, 13. April 2005 12:19 schrieb Pierre-Yves Delens:
> Bonjour,
Guten Tag,
> I'm developing my first ZODB app (without Zope).
> I need to display sorted items from a BTree.
> Sorting should happen by one of the fields value, not by key order.
You can use "decorate sort undecorate". There are some examples in
the python cookbook.
> - Is IndexedCatalog the good solution ?
You don't need indexedCatalog for sorting. If your
whole btree fits into memory you can use it like a python
dictionary.
I looked at IndexedCatalog, but diceded to use may own
Catalog which implements a small subset of the Index-API
of Zope2. IndexedCatalog is more implicit than explicit.
If I could do a rewrite of my app, I would have a look at
the indexes of Zope3.
Building simple indexes with btrees is not dificult:
Just map the value of your object to the ID of your object:
catalog.name["Pierre"]=.... # Every object has an integer ID in my app.
Be sure to write unittests, which check that the (redundant) data of
the catalog don't get out of sync.
HTH,
Thomas
--
Thomas Güttler, TBZ-PARIV GmbH, Bernsdorfer Str. 210-212, 09126 Chemnitz
Tel.: 0371/5221217 Fax: 0371/5221216
More information about the ZODB-Dev
mailing list