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)
    >>> list(result) == [o4, o5]

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...



Zope3-users mailing list

Reply via email to