[Zope-dev] ZCatalog: text searches fail with sort_on + patch

Steve Alexander steve@cat-box.net
Fri, 01 Sep 2000 19:56:04 +0100


This is a multi-part message in MIME format.
--------------AAD3D7E17ECC31E9DA4E6570
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm getting an error in Catalog when I specify sort_on on a field-index,
and also search on a text index.

Zope 2.2.1, Python 1.5.2


Error Type: TypeError
Error Value: loop over non-sequence

Traceback (innermost last):
  File lib/python/ZPublisher/Publish.py, line 222, in publish_module
  File lib/python/ZPublisher/Publish.py, line 187, in publish
  File lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
    (Object: ProviderContainer)
  File lib/python/ZPublisher/Publish.py, line 171, in publish
  File lib/python/ZPublisher/mapply.py, line 160, in mapply
    (Object: search)
  File lib/python/ZPublisher/Publish.py, line 112, in call_object
    (Object: search)
  File lib/python/OFS/DTMLDocument.py, line 177, in __call__
    (Object: search)
  File lib/python/DocumentTemplate/DT_String.py, line 528, in __call__
    (Object: search)
  File lib/python/DocumentTemplate/DT_In.py, line 630, in renderwob
    (Object: SiteIndex)
  File lib/python/Products/ZCatalog/ZCatalog.py, line 463, in
searchResults
    (Object: Traversable)
  File lib/python/Products/ZCatalog/Catalog.py, line 602, in
searchResults
  File lib/python/Products/ZCatalog/Catalog.py, line 555, in
_indexedSearch
TypeError: (see above)

This seems to be a simple type incompatibility error.

Attached is a patch that fixes this.

In Collector, http://classic.zope.org:8080/Collector/1586/view

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net
--------------AAD3D7E17ECC31E9DA4E6570
Content-Type: text/plain; charset=us-ascii;
 name="patch.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch.txt"

*** Catalog.py.orig
--- Catalog.py
***************
*** 552,558 ****
                          if intset: 
                              append((k,LazyMap(self.__getitem__, intset)))
                  else:
!                     for r in rs:
                          append((sort_index._unindex[r],
                                 LazyMap(self.__getitem__,[r])))
  
--- 552,558 ----
                          if intset: 
                              append((k,LazyMap(self.__getitem__, intset)))
                  else:
!                     for r,x in rs.items():
                          append((sort_index._unindex[r],
                                 LazyMap(self.__getitem__,[r])))
  

--------------AAD3D7E17ECC31E9DA4E6570--