[Zope-CVS] CVS: Products/QueueCatalog - QueueCatalog.py:1.15

Casey Duncan cvs-admin at zope.org
Thu Nov 6 17:12:23 EST 2003


Update of /cvs-repository/Products/QueueCatalog
In directory cvs.zope.org:/tmp/cvs-serv3290

Modified Files:
	QueueCatalog.py 
Log Message:
Add uidForObject hook which allows the underlying catalog to specify uids for new objects being indexed. If this hook is not implemented, uids are abs paths as before.


=== Products/QueueCatalog/QueueCatalog.py 1.14 => 1.15 ===
--- Products/QueueCatalog/QueueCatalog.py:1.14	Wed Jun 25 16:41:04 2003
+++ Products/QueueCatalog/QueueCatalog.py	Thu Nov  6 17:11:42 2003
@@ -299,7 +299,7 @@
             if max:
                 # limit the number of events
                 limit = max - count
-
+        
             events = queue.process(limit)
 
             for uid, (t, event) in events.items():
@@ -332,14 +332,13 @@
     def indexObject(self, object):
         """Add to catalog.
         """
-        self.catalog_object(object)
+        self.catalog_object(object, self.uidForObject(object))
 
     security.declarePrivate('unindexObject')
     def unindexObject(self, object):
         """Remove from catalog.
         """
-        url = '/'.join(object.getPhysicalPath())
-        self.uncatalog_object(url)
+        self.uncatalog_object(self.uidForObject(object))
 
     security.declarePrivate('reindexObject')
     def reindexObject(self, object, idxs=[]):
@@ -349,7 +348,19 @@
         to update (all of them by default).
         """
         # Punt for now and ignore idxs.
-        self.catalog_object(object)
+        self.catalog_object(object, self.uidForObject(object))
+
+    security.declarePrivate('uidForObject')
+    def uidForObject(self, obj):
+        """Get a catalog uid for the object. Allows the underlying catalog
+        to determine the uids if it implements this method"""
+        catalog = self.getZCatalog()
+        try:
+            uidForObject = aq_base(catalog).uidForObject
+        except AttributeError:
+            return '/'.join(obj.getPhysicalPath())
+        else:
+            return uidForObject(obj)
 
     # Provide web pages. It would be nice to use views, but Zope 2.6
     # just isn't ready for views. :( In particular, we'd have to fake




More information about the Zope-CVS mailing list