[Zope-dev] Xron and Zope 2.4.0 again

Steve Alexander steve@cat-box.net
Thu, 26 Jul 2001 20:44:04 +0100


Loren Stafford wrote:
>>I'm trying to use Zope 2.4.0 and Xron 0.0.9 on win98 (I've
>>applied the patch
>>to change "from Globals import DateTime" into "from DateTime import
>>DateTime")
>>
> 
> [snip]
> 
> 
>>  File C:\Zope\lib\python\Products\ZCatalog\Catalog.py, line 348, in
>>addIndex
>>TypeError: Catalog addIndex now requires the index type to
>>            be resolved prior to adding; create the proper index in the
>>caller.
>>
> 
> [snip]
> 
> 
>>I've seen messages from users saying that Xron with the patch worked fine
>>for them with Zope 2.4.0.
>>So why doesn't it work for me ?
>>
> 
> Probably because you are creating a new Schedule Zcatalog, whereas they were
> using one already created in a prior version of Zope.
> 
> As far as I can tell the addIndex error results from changes to Catalog.py
> made to support PluggableIndexes. I haven't been paying attention to this
> development, so I have no clue what to do to make Xron compatible with
> PluggableIndexes.
> 
> Can anyone point me in the right direction?

Before you might have done this:

self._catalog.addIndex('name', 'FieldIndex')

You now need to do this:

self._catalog.addIndex('name', UnIndex('name'))

The same goes for KeywordIndex (UnKeywordIndex) and TextIndex 
(UnTextIndex).

You'll also need

from SearchIndex.UnIndex import UnIndex
from SearchIndex.UnTextIndex import UnTextIndex
from SearchIndex.UnKeywordIndex import UnKeywordIndex

in there somewhere.

I patched tracked to adapt to either the old or new styles:

     field_indexes=('type', 'numid', 'exemptions', 'date', 'stage',
                    'priority', 'requester', 'from', 'private')
     keyword_indexes=('issueOwners','subscribers','traitVals')
     text_indexes=('text_content',)
     addIndex=self._catalog.addIndex
     # try to add indexes in Zope 2.3 style. If this fails
     # then add them in Zope 2.4 style
     try:
         for name in field_indexes:
             addIndex(name, 'FieldIndex')
         for name in keyword_indexes:
             addIndex(name, 'KeywordIndex')
         for name in text_indexes:
             addIndex(name, 'TextIndex')
     except TypeError:
         from SearchIndex.UnIndex import UnIndex
         from SearchIndex.UnTextIndex import UnTextIndex
         from SearchIndex.UnKeywordIndex import UnKeywordIndex

         for name in field_indexes:
             addIndex(name, UnIndex(name))
         for name in keyword_indexes:
             addIndex(name, UnKeywordIndex(name))
         for name in text_indexes:
             addIndex(name, UnTextIndex(name))

--
Steve Alexander
Software Engineer
Cat-Box limited