[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - Catalog.py:1.114 IZCatalog.py:1.7 ZCatalog.py:1.127

Chris McDonough chrism at zope.com
Tue Oct 7 14:21:28 EDT 2003


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

Modified Files:
	Catalog.py IZCatalog.py ZCatalog.py 
Log Message:
Revert feature of never updaing metadata if index is specified in catalog_object.  This broke several applications.  Instead, we provide the catalog_object method (and the Catalog.py's catalogObject method) with an update_metadata keyword argument.  If the update_metadata keyword argument is set false (the default is true), metadata is not updated.


=== Zope/lib/python/Products/ZCatalog/Catalog.py 1.113 => 1.114 ===
--- Zope/lib/python/Products/ZCatalog/Catalog.py:1.113	Sun Oct  5 10:08:11 2003
+++ Zope/lib/python/Products/ZCatalog/Catalog.py	Tue Oct  7 14:20:58 2003
@@ -328,15 +328,23 @@
         
     # the cataloging API
 
-    def catalogObject(self, object, uid, threshold=None,idxs=None):
+    def catalogObject(self, object, uid, threshold=None, idxs=None,
+                      update_metadata=1):
         """
-        Adds an object to the Catalog by iteratively applying it
+        Adds an object to the Catalog by iteratively applying it to
         all indexes.
 
         'object' is the object to be cataloged
 
         'uid' is the unique Catalog identifier for this object
 
+        If 'idxs' is specified (as a sequence), apply the object only
+        to the named indexes.
+
+        If 'update_metadata' is true (the default), also update metadata for
+        the object.  If the object is new to the catalog, this flag has
+        no effect (metadata is always created for new objects).
+
         """
 
         if idxs is None:
@@ -354,11 +362,8 @@
             self.uids[uid] = index
             self.paths[index] = uid
 
-        else:  # we are updating old data
-            if not idxs:
-                # if the caller specifies that we should update only a
-                # specific set of indexes, we don't do a metadata update.
-                self.updateMetadata(object, uid)
+        elif update_metadata:  # we are updating and we need to update metadata
+            self.updateMetadata(object, uid)
 
         # do indexing
 


=== Zope/lib/python/Products/ZCatalog/IZCatalog.py 1.6 => 1.7 ===
--- Zope/lib/python/Products/ZCatalog/IZCatalog.py:1.6	Mon Jun  9 16:02:48 2003
+++ Zope/lib/python/Products/ZCatalog/IZCatalog.py	Tue Oct  7 14:20:58 2003
@@ -66,13 +66,18 @@
 
     """
 
-    def catalog_object(obj, uid, idxs=[]):
+    def catalog_object(obj, uid, idxs=None, update_metadata=1):
         """Catalogs the object 'obj' with the unique identifier 'uid'.
 
         The uid must be a physical path, either absolute or relative to
         the catalog.
 
         If provided, idxs specifies the names of indexes to update.
+
+        If update_metadata is specified (the default), the object's metadata
+        is updated.  If it is not, the metadata is left untouched.  This
+        flag has no effect if the object is not yet cataloged (metadata
+        is always added for new objects).
         """
 
     def uncatalog_object(uid):


=== Zope/lib/python/Products/ZCatalog/ZCatalog.py 1.126 => 1.127 ===
--- Zope/lib/python/Products/ZCatalog/ZCatalog.py:1.126	Mon Jun  9 16:02:48 2003
+++ Zope/lib/python/Products/ZCatalog/ZCatalog.py	Tue Oct  7 14:20:58 2003
@@ -454,7 +454,9 @@
             if not obj:
                 obj = self.resolve_url(p, REQUEST)
             if obj is not None:
-                self.catalog_object(obj, p, idxs=[name])
+                # don't update metadata when only reindexing a single
+                # index via the UI
+                self.catalog_object(obj, p, idxs=[name], update_metadata=0)
 
 
     def manage_reindexIndex(self, ids=None, REQUEST=None, RESPONSE=None,
@@ -483,7 +485,7 @@
         return Splitter.availableSplitters
 
 
-    def catalog_object(self, obj, uid=None, idxs=[]):
+    def catalog_object(self, obj, uid=None, idxs=None, update_metadata=1):
         """ wrapper around catalog """
 
         if uid is None:
@@ -497,7 +499,8 @@
         elif not isinstance(uid,types.StringType):
             raise CatalogError('The object unique id must be a string.')
 
-        self._catalog.catalogObject(obj, uid, None,idxs)
+        self._catalog.catalogObject(obj, uid, None, idxs,
+                                    update_metadata=update_metadata)
         # None passed in to catalogObject as third argument indicates
         # that we shouldn't try to commit subtransactions within any
         # indexing code.  We throw away the result of the call to




More information about the Zope-Checkins mailing list