Commit 7570aeaf authored by Andreas Jung's avatar Andreas Jung

- Collector #1595: same as in Collector #1132 for indexes derived from

   UnIndex. Exisiting ZCatalog instances must be converted manually
   by calling the "manage_convertIndexes" method through-the-web for 
   every single ZCatalog instance.

- added manage_convertIndexes()

- removed manage_convertIndex() (obsolete)
parent e22ce2fb
......@@ -381,6 +381,11 @@ Zope Changes
from such an old version to Zope 2.8, you need to clear and reindex
your ZCatalog).
- Collector #1595: same as in Collector #1132 for indexes derived from
UnIndex. Exisiting ZCatalog instances must be converted manually
by calling the "manage_convertIndexes" method through-the-web for
every single ZCatalog instance.
- Collector #1457: ZCTextIndex's QueryError and ParseError
are now available for import from untrusted code.
......
......@@ -39,6 +39,7 @@ from Products.PluginIndexes.common.PluggableIndex \
from Products.PluginIndexes.TextIndex import Splitter
from IZCatalog import IZCatalog
from ProgressHandler import ZLogHandler
from zLOG import LOG, INFO
LOG = logging.getLogger('Zope.ZCatalog')
......@@ -902,52 +903,39 @@ class ZCatalog(Folder, Persistent, Implicit):
self.pgthreshold = 0
return self.pgthreshold
def manage_convertBTrees(self, threshold=200):
"""Convert the catalog's data structures to use BTrees package"""
assert type(threshold) is type(0)
tt=time.time()
ct=time.clock()
self._catalog._convertBTrees(threshold)
tt=time.time()-tt
ct=time.clock()-ct
return 'Finished conversion in %s seconds (%s cpu)' % (tt, ct)
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
converted = []
for id in ids:
idx = self.Indexes[id]
iface = getattr(idx,'__implements__',None)
if iface is None:
def manage_convertIndexes(self, REQUEST=None, RESPONSE=None, URL1=None):
"""Recreate indexes derived from UnIndex because the implementation of
__len__ changed in Zope 2.8. Pre-Zope 2.7 installation used to implement
__len__ as persistent attribute of the index instance which is totally
incompatible with the new extension class implementation based on new-style
classes.
"""
mt = idx.meta_type
LOG.info('Start migration of indexes for %s' % self.absolute_url(1))
converted.append(id)
self.delIndex(id)
for idx in self.Indexes.objectValues():
bases = [str(name) for name in idx.__class__.__bases__]
found = False
for base in bases:
if 'UnIndex' in base:
found = True
break
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')
if found:
idx_type = idx.meta_type
idx_id = idx.getId()
LOG.info('processing index %s' % idx_id)
indexed_attrs = getattr(idx, 'indexed_attrs', None)
self.delIndex(idx.getId())
self.addIndex(idx_id, idx_type)
new_idx = self.Indexes[idx_id]
if indexed_attrs:
setattr(new_idx, 'indexed_attrs', indexed_attrs)
self.manage_reindexIndex(idx_id, REQUEST)
if converted:
RESPONSE.redirect(
URL1 +
'/manage_main?manage_tabs_message=Indexes%20converted')
else:
RESPONSE.redirect(
URL1 +
'/manage_main?'
'manage_tabs_message='
'No%20indexes%20found%20to%20be%20converted')
'/manage_main?manage_tabs_message=Indexes%20converted%20and%20reindexed')
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment