[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - Catalog.py:1.98.6.12 IZCatalog.py:1.4.2.4 ZCatalog.py:1.121.2.3

Chris McDonough chrism at zope.com
Tue Oct 7 15:43:55 EDT 2003


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

Modified Files:
      Tag: Zope-2_6-branch
	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.98.6.11 => 1.98.6.12 ===
--- Zope/lib/python/Products/ZCatalog/Catalog.py:1.98.6.11	Wed Aug  6 16:50:56 2003
+++ Zope/lib/python/Products/ZCatalog/Catalog.py	Tue Oct  7 15:43:24 2003
@@ -324,7 +324,6 @@
                 else:
                     index=0
                 # meta_data is stored as a tuple for efficiency
-                newDataRecord = self.recordify(object)
                 data[index] = newDataRecord
         else:
             if data.get(index, 0) != newDataRecord:
@@ -333,15 +332,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:
             idxs = []
@@ -358,11 +365,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.4.2.3 => 1.4.2.4 ===
--- Zope/lib/python/Products/ZCatalog/IZCatalog.py:1.4.2.3	Mon Jun  9 15:52:38 2003
+++ Zope/lib/python/Products/ZCatalog/IZCatalog.py	Tue Oct  7 15:43:24 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.121.2.2 => 1.121.2.3 ===
--- Zope/lib/python/Products/ZCatalog/ZCatalog.py:1.121.2.2	Mon Mar  3 13:14:27 2003
+++ Zope/lib/python/Products/ZCatalog/ZCatalog.py	Tue Oct  7 15:43:24 2003
@@ -454,7 +454,7 @@
             if not obj:
                 obj = self.resolve_url(p, REQUEST)
             if obj is not None:
-                self.catalog_object(obj, p, idxs=[name])
+                self.catalog_object(obj, p, idxs=[name], update_metadata=0)
 
 
     def manage_reindexIndex(self, ids=None, REQUEST=None, RESPONSE=None,
@@ -483,7 +483,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 +497,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