[Zope-CMF] Portal catalog searchs fail
Tres Seaver
tseaver@zope.com
06 May 2002 10:44:54 -0400
On Mon, 2002-05-06 at 10:01, Itamar Shtull-Trauring wrote:
> I'm doing the following as Anonymous and it fails with a traceback - it
> works fine as Manager(!!!). There are 0 items catalogged at the moment, but
> same error when some are. CMF 1.2, Zope 2.4. The issue is obviously with the
> changes CatalogTool does to queries, but I can't see how no one ever found
> this bug before.
>
> Search:
> return container.portal_catalog.searchResults(
> meta_type='CMF Event', review_state='published')
>
>
> Traceback:
> ...
> File
> /Services/www/zope2.4/lib/python/Products/PythonScripts/PythonScript.py,
> line 363, in _exec
> (Object: getEvents)
> (Info: ({'script': <PythonScript instance at 91c4838>, 'context':
> <CMFSite instance at 8b5b578>, 'container': <CMFSite instance at
> 8b5b578>, 'traverse_subpath': []}, (), {}, None))
> File Script (Python), line 1, in getEvents
> (Object: guarded_getattr)
> File /Services/www/zope2.4/lib/python/Products/CMFCore/CatalogTool.py,
> line 193, in searchResults
> (Object: portal_catalog)
> File /Services/www/zope2.4/lib/python/Products/ZCatalog/ZCatalog.py, line
> 653, in searchResults
> (Object: portal_catalog)
> File /Services/www/zope2.4/lib/python/Products/ZCatalog/Catalog.py, line
> 650, in searchResults
> File /Services/www/zope2.4/lib/python/Products/ZCatalog/Catalog.py, line
> 538, in _indexedSearch
> File
> /Services/www/zope2.4/lib/python/Products/PluginIndexes/common/UnIndex.py,
> line 402, in _apply_index
> (Object: expires)
> AttributeError: find
I think you are vicitm here to the problem that indexes created under
Zope 2.3 break under Zope 2.4+; Andreas has added a method to the
catalog on the head to do the upgrade; it looks like it will work as an
ExternalMethod as well::
def manage_convertIndex(self, ids, REQUEST=None,
RESPONSE=None, URL1=None):
"""convert old-style indexes to new-style indexes"""
from Products.PluginIndexes.KeywordIndex import KeywordIndex
from Products.PluginIndexes.FieldIndex import FieldIndex
from Products.PluginIndexes.TextIndex import TextIndex
from Acquisition import aq_base
import copy
converted = []
for id in ids:
idx = self.Indexes[id]
iface = getattr(idx,'__implements__',None)
if iface is None:
mt = idx.meta_type
converted.append(id)
self.delIndex(id)
if mt in ('Field Index','Keyword Index'):
self.addIndex(id,mt.replace(' ',''))
elif mt == 'Text Index':
# TODO: Lexicon handling to be added
self.addIndex(id,'TextIndex')
RESPONSE.redirect(URL1
+ '/manage_main?manage_tabs_message='
+ '%d%20indexes%20converted' + len(converted))
Note that you will also need to delete and re-add the Vocabulary
object, and then re-index the catalog.
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com