[Zope] ZCatalog and random key error

Erik Enge erik@esol.no
Fri, 10 Nov 2000 11:49:17 +0100 (CET)


On Fri, 10 Nov 2000, Bak @ kedai wrote:

> also, will iterating through catalog index faster than iterating through 
> ..say.. objectItems('meta-type')?

Much faster.  Much, much faster.  I tried an objectValues() on 2000 items
(in 3 different folder-type objects) and did various calculations on each
object, it took me 20 sec. to render the page.  On the same box the
Catalog return a search (much wider than the one on 2000 objects) on 15000
items (indexd, natuarally) within a second or two.

Hm.  I might be getting out on thin ice now, but I think it depends on
what you want to do with the objects you get back from your
iteration.  If you just are looking for simple attributes, the Catalog
should suffice, but it (the Catalog) might be slower if you are doing
something with the objects, since it has to fetch them first - and the
objectValues() returns the object.  I'm not sure about this, though, the
source code should help you a lot (I think objectValues() and
objectItems() and those alike are in lib/python/ObjectManager.py -
around line 350).

Come to think of it.  You did say objectItems(), and I've described the
objectValues().  I don't think you can compare the Catalog and
objectItems(), since objectItems() returns a list of (id,
subobject) tuples and thus gives you context - something the Catalog
cannot do (unless you hack it.. yeah Catalog wizards?).

I might be wrong though :)