[Zope3-Users] FieldIndex on boolean field - error
Hi, I'm trying to index a boolean field of some object, to simplify retrieving all the objects which have some flag turned on. I am adding in proper place the index: catalog['anomaly'] = FieldIndex('anomaly', IMyObject) But then, when I try to get the objects using the following command, I get an exception. Is FieldIndex able to index bool field? If not, how to create own index for doing that? anomalies = catalog.searchResults(anomaly=True) File "C:\Python24\Lib\site-packages\zope\app\catalog\catalog.py", line 121, in searchResults results = self.apply(searchterms) File "C:\Python24\Lib\site-packages\zope\app\catalog\catalog.py", line 100, in apply r = index.apply(index_query) File "C:\Python24\Lib\site-packages\zope\index\field\index.py", line 99, in apply if len(query) != 2 or not isinstance(query, tuple): TypeError: len() of unsized object ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] FieldIndex on boolean field - error
Hi, On Wed, Mar 28, 2007 at 03:55:28PM +, Alek Kowalczyk wrote: > Hi, > I'm trying to index a boolean field of some object, to simplify retrieving all > the objects which have some flag turned on. > > I am adding in proper place the index: > > catalog['anomaly'] = FieldIndex('anomaly', IMyObject) > > But then, when I try to get the objects using the following command, I get an > exception. Is FieldIndex able to index bool field? If not, how to create own > index for doing that? > > anomalies = catalog.searchResults(anomaly=True) [snip] > TypeError: len() of unsized object A fieldindex always requires a lower and an upper boundary, found objects must fit into. Try catalog.searchResults(anomaly=(True,True)) BTW: The error is raised because the fieldindex tries to interpret 'True' as a tuple. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] FieldIndex on boolean field - error
On 3/28/07, FB <[EMAIL PROTECTED]> wrote: Hi, On Wed, Mar 28, 2007 at 03:55:28PM +, Alek Kowalczyk wrote: > Hi,Is FieldIndex able to index bool field? If not, how to create own > index for doing that? > > anomalies = catalog.searchResults(anomaly=True) Try catalog.searchResults(anomaly=(True,True)) BTW: The error is raised because the fieldindex tries to interpret 'True' as a tuple. Thanks! I didn't think that the solution is so simple. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users