[Zope-CVS] CVS: Products/QueueCatalog - CatalogEventQueueSet.py:1.2
Tres Seaver
tseaver@zope.com
Wed, 4 Jun 2003 16:04:41 -0400
Update of /cvs-repository/Products/QueueCatalog
In directory cvs.zope.org:/tmp/cvs-serv4203
Modified Files:
CatalogEventQueueSet.py
Log Message:
- Use SimpleItem, so we play nicer with acquisition.
- Add 'getEvent' method, to allow client to ask whether we know anything
about a UID.
- Move hashing code into helper method, '_getQueue'.
- Test explicitly for None (if the delegate is an empty catalog, it
won't test true).
=== Products/QueueCatalog/CatalogEventQueueSet.py 1.1 => 1.2 ===
--- Products/QueueCatalog/CatalogEventQueueSet.py:1.1 Wed Jun 4 11:15:21 2003
+++ Products/QueueCatalog/CatalogEventQueueSet.py Wed Jun 4 16:04:41 2003
@@ -6,7 +6,7 @@
from Interface import Interface
-from Persistence import Persistent
+from OFS.SimpleItem import SimpleItem
from Products.QueueCatalog.CatalogEventQueue import CatalogEventQueue
from Products.QueueCatalog.CatalogEventQueue import EVENT_TYPES
@@ -46,7 +46,7 @@
"""
-class CatalogEventQueueSet( Persistent ):
+class CatalogEventQueueSet( SimpleItem ):
""" Manage a set of CatalogEventQueue objects.
"""
@@ -74,6 +74,12 @@
"""
return self._bucket_count
+ def getEvent( self, uid ):
+
+ """ Return the most recent event, if any, for uid.
+ """
+ return self._getQueue( uid ).getEvent( uid )
+
def listEvents( self ):
""" Return all events we currently know about.
@@ -134,7 +140,7 @@
if event not in EVENT_TYPES:
raise ValueError, 'Not a known event: %s' % event
- self._queues[ hash( uid ) % self._bucket_count ].update( uid, event )
+ self._getQueue( uid ).update( uid, event )
def process( self ):
@@ -143,7 +149,7 @@
for queue in filter( None, self._queues ):
for item in queue.process().items():
- if not self._delegate:
+ if self._delegate is None:
continue
uid, ( t, event ) = item
@@ -158,6 +164,10 @@
#
# Helper methods
#
+ def _getQueue( self, uid ):
+
+ return self._queues[ hash( uid ) % self._bucket_count ]
+
def _clear( self ):
self._queues = [ CatalogEventQueue()