[Zope3-Users] zope.app.catalog doc question

Duncan McGreggor duncan.mcgreggor at gmail.com
Fri Sep 30 15:52:11 EDT 2005


I am curious about the documented catalog method searchResults().  
Starting at line 223 of zope/app/catalog/README.txt (3.1 rc3 download,  
not svn co), there is the following usage of the method:

     >>> result = cat.searchResults(size=5)
     >>> len(result)
     2
     >>> list(result) == [o4, o5]
     True

When trying to implement this with my own catalog, I got the following  
(partial) traceback:

   File  
"/Users/oubiwann/Desktop/2CD/AdytumSolutions/Projects/Zope3Work/ 
zope310_r3/lib/python/accumacsite/browser/homepageview.py", line 18, in  
inventoryInStock
     return catalog.searchResults(equipment_in_stock=True)
   File "/usr/local/zope310/lib/python/zope/app/catalog/catalog.py",  
line 105, in searchResults
     results = self.apply(searchterms)
   File "/usr/local/zope310/lib/python/zope/app/catalog/catalog.py",  
line 84, in apply
     r = index.apply(index_query)
   File "/usr/local/zope310/lib/python/zope/index/field/index.py", line  
99, in apply
     return multiunion(self._fwd_index.values(*query))
TypeError: values() argument after * must be a sequence

Indeed, after looking at the code, it seems that instead of writing  
this:

   return catalog.searchResults(equipment_in_stock=True)

I should be writing this:

   return catalog.searchResults(equipment_in_stock=[True])

since apply() does expect the rhs of the parameter to be a sequence.  
With this change, my code now works (no errors, anyway), but I wanted  
to see if this was a misunderstanding on my part or a documentation  
typo...

Thanks,

Duncan



More information about the Zope3-users mailing list