source: WAeUP_SRP/branches/joachim-azax-branch/PatchQueueCatalogProcessQueue.py @ 14212

Last change on this file since 14212 was 1934, checked in by joachim, 17 years ago

fix for #283

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1import sets
2from Products.QueueCatalog.CatalogEventQueue import CatalogEventQueue, EVENT_TYPES, ADDED_EVENTS
3from Products.QueueCatalog.CatalogEventQueue import ADDED, CHANGED, CHANGED_ADDED, REMOVED
4from Products.QueueCatalog.CatalogEventQueue import SAFE_POLICY, ALTERNATIVE_POLICY
5from Products.QueueCatalog.QueueCatalog import cataloged
6
7def _process_queue(self, queue, limit):
8    """Process a single queue"""
9    catalog = self.getZCatalog()
10
11    if self.getProcessAllIndexes():
12        #idxs = None
13        idxs = catalog.indexes()
14    else:
15        cat_indexes = sets.Set(catalog.indexes())
16        immediate_indexes = sets.Set(self._immediate_indexes)
17        if not immediate_indexes or immediate_indexes==cat_indexes:
18            idxs = catalog.indexes() # do all of 'em
19        else:
20            idxs = list(cat_indexes - immediate_indexes)
21    events = queue.process(limit)
22    count = 0
23
24    for uid, (t, event) in events.items():
25        if event is REMOVED:
26            try:
27                if cataloged(catalog, uid):
28                    catalog.uncatalog_object(uid)
29            except (ConflictError, ClientDisconnected):
30                raise
31            except:
32                logger.error('error uncataloging object', exc_info=True)
33        else:
34            # add or change
35            if event is CHANGED and not cataloged(catalog, uid):
36                continue
37            # Note that the uid may be relative to the catalog.
38            obj = catalog.unrestrictedTraverse(uid, None)
39            if obj is not None:
40                immediate_metadata = self.getImmediateMetadataUpdate()
41                try:
42                    catalog.catalog_object(
43                        obj, uid, idxs=idxs,
44                        update_metadata=not immediate_metadata)
45                except (ConflictError, ClientDisconnected):
46                    raise
47                except:
48                    logger.error('error cataloging object', exc_info=True)
49
50        count = count + 1
51
52    return count
53from Products.QueueCatalog.QueueCatalog import QueueCatalog
54QueueCatalog._process_queue = _process_queue
Note: See TracBrowser for help on using the repository browser.