[Zope-CVS] CVS: Products/QueueCatalog - CatalogEventQueue.py:1.2 Processor.py:1.3 QueueCatalog.py:1.9 __init__.py:1.3

Shane Hathaway shane@cvs.zope.org
Tue, 15 Oct 2002 10:55:15 -0400


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

Modified Files:
	CatalogEventQueue.py Processor.py QueueCatalog.py __init__.py 
Log Message:
Brought in sync with internal repository.

- Added the ability to configure the number of buckets

- Removed mistaken changes to QueueCatalog.py (the exception handlers were
too greedy)

- Rearranged the imports in QueueCatalog.py to make them easier to read


=== Products/QueueCatalog/CatalogEventQueue.py 1.1 => 1.2 ===


=== Products/QueueCatalog/Processor.py 1.2 => 1.3 ===


=== Products/QueueCatalog/QueueCatalog.py 1.8 => 1.9 ===
--- Products/QueueCatalog/QueueCatalog.py:1.8	Mon Oct 14 13:27:49 2002
+++ Products/QueueCatalog/QueueCatalog.py	Tue Oct 15 10:55:14 2002
@@ -14,7 +14,11 @@
 """
 $Id$
 """
+# Python std. lib
+from time import time
+from types import StringType
 
+# Other packages
 from zExceptions import Unauthorized
 from ExtensionClass import Base
 from OFS.SimpleItem import SimpleItem
@@ -23,13 +27,14 @@
 from AccessControl.Permissions import manage_zcatalog_entries
 from OFS.SimpleItem import SimpleItem
 from BTrees.OOBTree import OOBTree
-from time import time
-from CatalogEventQueue import CatalogEventQueue, EVENT_TYPES, ADDED_EVENTS
-from CatalogEventQueue import ADDED, CHANGED, CHANGED_ADDED, REMOVED
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from Globals import DTMLFile
 from Acquisition import Implicit, aq_base, aq_inner, aq_parent
-from types import StringType
+
+# Local
+from CatalogEventQueue import CatalogEventQueue, EVENT_TYPES, ADDED_EVENTS
+from CatalogEventQueue import ADDED, CHANGED, CHANGED_ADDED, REMOVED
+
 
 _zcatalog_methods = {
     'catalog_object': 1,
@@ -122,6 +127,7 @@
                 res.append({'id': id, 'meta_type': meta_type})
             return res
 
+
     def getImmediateIndexes(self):
         return self._immediate_indexes
 
@@ -136,6 +142,16 @@
         self._immediate_removal = not not flag
 
 
+    def getBucketCount(self):
+        return self._buckets
+
+    def setBucketCount(self, count):
+        if self._location:
+            self.process()
+        self._buckets = int(count)
+        self._clearQueues()
+
+
     def getZCatalog(self, method=''):
         ZC = None
         REQUEST = getattr(self, 'REQUEST', None)
@@ -239,10 +255,7 @@
 
         if self._immediate_indexes:
             # Update some of the indexes immediately.
-            try:
-                catalog.catalog_object(obj, uid, self._immediate_indexes)
-            except:
-                pass
+            catalog.catalog_object(obj, uid, self._immediate_indexes)
 
 
     def uncatalog_object(self, uid):
@@ -274,11 +287,7 @@
                         continue
                     # Note that the uid may be relative to the catalog.
                     obj = catalog.unrestrictedTraverse(uid)
-                    try:
-                        catalog.catalog_object(obj, uid)
-                    except:
-                        # Something went wrong, put back in the queue
-                        self._update(uid, event)
+                    catalog.catalog_object(obj, uid)
 
     #
     # CMF catalog tool methods.
@@ -317,12 +326,16 @@
         return self._location or ''
 
     def manage_edit(self, title='', location='', immediate_indexes=(),
-                    immediate_removal=0, RESPONSE=None):
+                    immediate_removal=0, bucket_count=0, RESPONSE=None):
         """ Edit the instance """
         self.title = title
         self.setLocation(location or None)
         self.setImmediateIndexes(immediate_indexes)
         self.setImmediateRemoval(immediate_removal)
+        if bucket_count:
+            bucket_count = int(bucket_count)
+            if bucket_count != self.getBucketCount():
+                self.setBucketCount(bucket_count)
 
         if RESPONSE is not None:
             RESPONSE.redirect('%s/manage_editForm?manage_tabs_message='
@@ -379,7 +392,7 @@
         'manage_editForm', 'manage_edit',
         'manage_queue', 'manage_getLocation',
         'manage_size', 'getIndexInfo', 'getImmediateIndexes',
-        'getImmediateRemoval',
+        'getImmediateRemoval', 'getBucketCount', 'setBucketCount',
         )
     
 def cataloged(catalog, path):


=== Products/QueueCatalog/__init__.py 1.2 => 1.3 ===
--- Products/QueueCatalog/__init__.py:1.2	Tue Aug  6 12:55:33 2002
+++ Products/QueueCatalog/__init__.py	Tue Oct 15 10:55:14 2002
@@ -29,7 +29,7 @@
     "Add a Catalog Queue"
     ob = QueueCatalog()
     ob.id = id
-    ob.manage_edit(title, location)
+    ob.manage_edit(title, location, immediate_removal=1)
     self._setObject(id, ob)
 
     if REQUEST is not None: