[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - ZCatalog.py:1.126.2.4

Andreas Jung andreas at andreas-jung.com
Thu May 13 14:11:18 EDT 2004


Update of /cvs-repository/Zope/lib/python/Products/ZCatalog
In directory cvs.zope.org:/tmp/cvs-serv716/lib/python/Products/ZCatalog

Modified Files:
      Tag: Zope-2_7-branch
	ZCatalog.py 
Log Message:
     - Recataloging a ZCatalog instance is now more safe and predictable.
       Indexing errors are catched and logged. In addition the progress of the
       recataloging operation is logged. So one can see how much documents are
       already processed and how much documents are remaining.


=== Zope/lib/python/Products/ZCatalog/ZCatalog.py 1.126.2.3 => 1.126.2.4 ===
--- Zope/lib/python/Products/ZCatalog/ZCatalog.py:1.126.2.3	Fri Mar 19 08:23:25 2004
+++ Zope/lib/python/Products/ZCatalog/ZCatalog.py	Thu May 13 14:11:16 2004
@@ -31,12 +31,14 @@
 from AccessControl.Permissions import \
     manage_zcatalog_entries, manage_zcatalog_indexes, search_zcatalog
 from ZCatalogIndexes import ZCatalogIndexes
+from ZODB.POSException import ConflictError
 from Products.PluginIndexes.common.PluggableIndex \
      import PluggableIndexInterface
 from Products.PluginIndexes.TextIndex import Splitter
-import urllib, time, types
-import string
+import urllib, time, sys
+import string, logging
 from IZCatalog import IZCatalog
+from zLOG import LOG, INFO, BLATHER
 
 
 manage_addZCatalogForm=DTMLFile('dtml/addZCatalog',globals())
@@ -213,7 +215,7 @@
     def manage_catalogObject(self, REQUEST, RESPONSE, URL1, urls=None):
         """ index Zope object(s) that 'urls' point to """
         if urls:
-            if isinstance(urls, types.StringType):
+            if isinstance(urls, str):
                 urls=(urls,)
 
             for url in urls:
@@ -232,7 +234,7 @@
         """ removes Zope object(s) 'urls' from catalog """
 
         if urls:
-            if isinstance(urls, types.StringType):
+            if isinstance(urls, str):
                 urls=(urls,)
 
             for url in urls:
@@ -271,12 +273,26 @@
             paths = tuple(paths)
             cat.clear()
 
-        for p in paths:
+        LOG('ZCatalog', BLATHER, 'Starting recataloging of ZCatalog at %s' % 
+             self.absolute_url(1))
+        num_objects = len(paths)
+        for i in xrange(num_objects):
+            p = paths[i]
             obj = self.resolve_path(p)
             if not obj:
                 obj = self.resolve_url(p, self.REQUEST)
             if obj is not None:
-                self.catalog_object(obj, p)
+                try:
+                    LOG('ZCatalog', BLATHER, 'Recataloging object %s (%d/%d)' %
+                         (p, i, num_objects))
+                    self.catalog_object(obj, p)
+                except ConflictError:
+                    raise
+                except:
+                    LOG('ZCatalog', ERROR, 'Recataloging object at %s failed' % p,
+                              error=sys.exc_info())
+
+        LOG('ZCatalog', BLATHER, 'Recataloging of ZCatalog at %s terminated' % self.absolute_url(1))
 
     def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
         """ clears the whole enchilada """
@@ -363,7 +379,7 @@
 
     def manage_delColumn(self, names, REQUEST=None, RESPONSE=None, URL1=None):
         """ delete a column or some columns """
-        if isinstance(names, types.StringType):
+        if isinstance(names, str):
             names = (names,)
 
         for name in names:
@@ -413,7 +429,7 @@
                 message='No items were specified!',
                 action = "./manage_catalogIndexes",)
 
-        if isinstance(ids, types.StringType):
+        if isinstance(ids, str):
             ids = (ids,)
 
         for name in ids:
@@ -433,7 +449,7 @@
                 message='No items were specified!',
                 action = "./manage_catalogIndexes",)
 
-        if isinstance(ids, types.StringType):
+        if isinstance(ids, str):
             ids = (ids,)
 
         for name in ids:
@@ -477,7 +493,7 @@
                 message='No items were specified!',
                 action = "./manage_catalogIndexes",)
 
-        if isinstance(ids, types.StringType):
+        if isinstance(ids, str):
             ids = (ids,)
 
         for name in ids:
@@ -506,7 +522,7 @@
                     "method if no unique id is provided when cataloging"
                     )
             else: uid='/'.join(uid())
-        elif not isinstance(uid,types.StringType):
+        elif not isinstance(uid,str):
             raise CatalogError('The object unique id must be a string.')
 
         self._catalog.catalogObject(obj, uid, None, idxs,




More information about the Zope-Checkins mailing list