[Zope-dev] ZCatalog problems

Steve Alexander steve@cat-box.net
Mon, 26 Feb 2001 18:31:11 +0000


Morten W. Petersen wrote:

 > Hi guys,
 >
 > I'm having trouble making ZCatalog work.  The problem is that there
 > are 29 objects of a given meta type, with the same booleans that
 > should be returned for an iteration; but only 20 are.  Is this a
 > result of caching perhaps?  Or lazy results?

Could be that your objects have different ideas of what are proper 
boolean values.

I assume you're using a FieldIndex. Try calling 
uniqueValuesFor(index_name) to see what values are stored. You may find 
that you have 0, 1, '1' and '', for example.

In situations like that, I get the unique values, then construct a query 
for the catalog based on the true or false values.

To get the true values, something like

   Catalog(boolean_index=
        filter(None, Catalog.uniqueValuesFor('boolean_index'))

To get the false ones:

   Catalog(boolean_index=
         filter(lambda x: not x,
                Catalog.uniqueValuesFor('boolean_index'))

--
Steve Alexander
Software Engineer
Cat-Box limited