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

Chris McDonough chrism at zope.com
Sun Oct 5 10:08:42 EDT 2003


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

Modified Files:
	Catalog.py 
Log Message:
Merge 'dont-update-metadata' fix from 2.6 branch.  When the caller specifies that only a particular set of indexes should be updated, don't update the object metadata unconditionally.


=== Zope/lib/python/Products/ZCatalog/Catalog.py 1.112 => 1.113 ===
--- Zope/lib/python/Products/ZCatalog/Catalog.py:1.112	Thu Jul  3 13:36:27 2003
+++ Zope/lib/python/Products/ZCatalog/Catalog.py	Sun Oct  5 10:08:11 2003
@@ -287,35 +287,14 @@
         """ get an index wrapped in the catalog """
         return self.indexes[name].__of__(self)
 
-    # the cataloging API
-
-    def catalogObject(self, object, uid, threshold=None,idxs=[]):
-        """
-        Adds an object to the Catalog by iteratively applying it
-        all indexes.
-
-        'object' is the object to be cataloged
-
-        'uid' is the unique Catalog identifier for this object
-
-        """
-
+    def updateMetadata(self, object, uid):
+        """ Given an object and a uid, update the column data for the
+        uid with the object data iff the object has changed """
         data = self.data
-
-        # meta_data is stored as a tuple for efficiency
+        index = self.uids.get(uid, None)
         newDataRecord = self.recordify(object)
 
-        index=self.uids.get(uid, None)
-        if index is not None:
-            # old data
-
-            if data.get(index, 0) != newDataRecord:
-                # Update the meta-data, if necessary
-                data[index] = newDataRecord
-
-        else:
-            # new data
-
+        if index is None:
             if type(data) is IOBTree:
                 # New style, get random id
 
@@ -340,13 +319,48 @@
                     index = data.keys()[-1] + 1
                 else:
                     index=0
+                # meta_data is stored as a tuple for efficiency
                 data[index] = newDataRecord
+        else:
+            if data.get(index, 0) != newDataRecord:
+                data[index] = newDataRecord
+        return index
+        
+    # the cataloging API
+
+    def catalogObject(self, object, uid, threshold=None,idxs=None):
+        """
+        Adds an object to the Catalog by iteratively applying it
+        all indexes.
+
+        'object' is the object to be cataloged
+
+        'uid' is the unique Catalog identifier for this object
+
+        """
+
+        if idxs is None:
+            idxs = []
+
+        data = self.data
+        index = self.uids.get(uid, None)
+
+        if index is None:  # we are inserting new data
+            index = self.updateMetadata(object, uid)
 
             try: self.__len__.change(1)
             except AttributeError: pass # No managed length (old-style)
 
             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)
+
+        # do indexing
 
         total = 0
 




More information about the Zope-Checkins mailing list