Commit f1752106 authored by Chris Withers's avatar Chris Withers

- Removed unused imports

- refactored slightly
- logged when object cannot be resolved on re-indexing of an index
- made manage_reindexIndex more efficient.
parent 20a817b0
...@@ -36,10 +36,10 @@ from Products.PluginIndexes.common.PluggableIndex \ ...@@ -36,10 +36,10 @@ from Products.PluginIndexes.common.PluggableIndex \
import PluggableIndexInterface import PluggableIndexInterface
from Products.PluginIndexes.TextIndex import Splitter from Products.PluginIndexes.TextIndex import Splitter
import urllib, time, sys import urllib, time, sys
import string, logging import string,logging
from IZCatalog import IZCatalog from IZCatalog import IZCatalog
from zLOG import LOG, INFO, BLATHER, ERROR
LOG = logging.getLogger('Zope.ZCatalog')
manage_addZCatalogForm=DTMLFile('dtml/addZCatalog',globals()) manage_addZCatalogForm=DTMLFile('dtml/addZCatalog',globals())
...@@ -461,17 +461,20 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -461,17 +461,20 @@ class ZCatalog(Folder, Persistent, Implicit):
def reindexIndex(self, name, REQUEST): def reindexIndex(self, name, REQUEST):
paths = self._catalog.uids.keys() if isinstance(name, str):
name = (name,)
for p in paths: for p in self._catalog.uids.keys():
obj = self.resolve_path(p) obj = self.resolve_path(p)
if not obj: if not obj:
obj = self.resolve_url(p, REQUEST) obj = self.resolve_url(p, REQUEST)
if obj is not None: if obj is None:
LOG.error('reindexIndex could not resolve '
'an object from the uid %r.' % (uid))
else:
# don't update metadata when only reindexing a single # don't update metadata when only reindexing a single
# index via the UI # index via the UI
try: try:
self.catalog_object(obj, p, idxs=[name], self.catalog_object(obj, p, idxs=name,
update_metadata=0) update_metadata=0)
except TypeError: except TypeError:
# Fall back to Zope 2.6.2 interface. This is necessary for # Fall back to Zope 2.6.2 interface. This is necessary for
...@@ -495,8 +498,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -495,8 +498,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if isinstance(ids, str): if isinstance(ids, str):
ids = (ids,) ids = (ids,)
for name in ids: self.reindexIndex(name, REQUEST, ids)
self.reindexIndex(name, REQUEST)
if REQUEST and RESPONSE: if REQUEST and RESPONSE:
RESPONSE.redirect( RESPONSE.redirect(
......
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