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 ...@@ -381,6 +381,11 @@ Zope Changes
from such an old version to Zope 2.8, you need to clear and reindex from such an old version to Zope 2.8, you need to clear and reindex
your ZCatalog). 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 - Collector #1457: ZCTextIndex's QueryError and ParseError
are now available for import from untrusted code. are now available for import from untrusted code.
......
...@@ -39,6 +39,7 @@ from Products.PluginIndexes.common.PluggableIndex \ ...@@ -39,6 +39,7 @@ from Products.PluginIndexes.common.PluggableIndex \
from Products.PluginIndexes.TextIndex import Splitter from Products.PluginIndexes.TextIndex import Splitter
from IZCatalog import IZCatalog from IZCatalog import IZCatalog
from ProgressHandler import ZLogHandler from ProgressHandler import ZLogHandler
from zLOG import LOG, INFO
LOG = logging.getLogger('Zope.ZCatalog') LOG = logging.getLogger('Zope.ZCatalog')
...@@ -902,52 +903,39 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -902,52 +903,39 @@ class ZCatalog(Folder, Persistent, Implicit):
self.pgthreshold = 0 self.pgthreshold = 0
return self.pgthreshold return self.pgthreshold
def manage_convertBTrees(self, threshold=200): def manage_convertIndexes(self, REQUEST=None, RESPONSE=None, URL1=None):
"""Convert the catalog's data structures to use BTrees package""" """Recreate indexes derived from UnIndex because the implementation of
assert type(threshold) is type(0) __len__ changed in Zope 2.8. Pre-Zope 2.7 installation used to implement
tt=time.time() __len__ as persistent attribute of the index instance which is totally
ct=time.clock() incompatible with the new extension class implementation based on new-style
self._catalog._convertBTrees(threshold) classes.
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:
mt = idx.meta_type
converted.append(id)
self.delIndex(id)
if mt in ('Field Index','Keyword Index'): LOG.info('Start migration of indexes for %s' % self.absolute_url(1))
self.addIndex(id,mt.replace(' ',''))
elif mt == 'Text Index': for idx in self.Indexes.objectValues():
# TODO: Lexicon handling to be added bases = [str(name) for name in idx.__class__.__bases__]
self.addIndex(id,'TextIndex') found = False
for base in bases:
if 'UnIndex' in base:
found = True
break
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(
RESPONSE.redirect( URL1 +
URL1 + '/manage_main?manage_tabs_message=Indexes%20converted%20and%20reindexed')
'/manage_main?manage_tabs_message=Indexes%20converted')
else:
RESPONSE.redirect(
URL1 +
'/manage_main?'
'manage_tabs_message='
'No%20indexes%20found%20to%20be%20converted')
# #
......
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