[Zope-CMF] howto avoid loading of datetime-objects when accessing
a portal_catalog brain
Dieter Maurer
dieter at handshake.de
Fri Oct 19 13:34:43 EDT 2007
Joachim Schmitz wrote at 2007-10-19 10:03 +0200:
>If one iterates over the result of a portal_catalog search, for each
>brain there are about 8 datetime objects loaded (one for each
>dateindex), which quickly fills the memory.
>how can I access only the brain id
You can get the brain id via "brain.getRID()".
While it would not be necessary in principle (the "rid" is not part of
the meta data tuple) I am not sure whether access to the "rid"
nevertheless loads the tuple (and thereby your "DateTime" objects).
But you can access the rids avoiding the brains altogether:
The usual catalog result is a "Products.ZCatalog.Lazy.LazyMap"
instance. Its "_seq" attribute (obviously private) contains
the sequences of rids corresponding to the query hits.
--
Dieter
More information about the Zope-CMF
mailing list