Changeset 1865 in products
- Timestamp:
- Mar 9, 2010 6:56:34 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/utility.py
r1764 r1865 2 2 import transaction 3 3 from zope.interface import implements 4 from zope.component import getMultiAdapter 4 5 from zope.component import queryMultiAdapter 5 from plone.indexer.interfaces import IIndexableObject6 6 7 7 from Missing import MV … … 11 11 from Products.CMFCore.utils import getToolByName 12 12 from Products.ZCatalog.Catalog import safe_callable 13 from Products.CMFPlone.CatalogTool import register_bbb_indexers 14 from Products.CMFPlone.CatalogTool import _old_IIndexableObjectWrapper 13 14 15 try: 16 from plone.indexer.interfaces import IIndexableObject 17 except ImportError: 18 class IIndexableObject:pass 19 from plone.app.content.interfaces import IIndexableObjectWrapper \ 20 as _old_IIndexableObjectWrapper 21 from plone.app.content.interfaces import IIndexableObjectWrapper 22 23 register_bbb_indexers = lambda:None 24 25 IS_NEW = False 26 else: 27 from Products.CMFPlone.CatalogTool import register_bbb_indexers 28 from Products.CMFPlone.CatalogTool import _old_IIndexableObjectWrapper 29 30 IS_NEW = True 31 15 32 16 33 from quintagroup.catalogupdater.interfaces import ICatalogUpdater … … 44 61 return _cat, cols 45 62 46 def getWrapedObject(self, obj, portal, catalog): 47 # Returned wrapped 'obj' object with IIndexable wrapper 48 w = obj 49 if not IIndexableObject.providedBy(obj): 50 # BBB: Compatibility wrapper lookup. Should be removed in Plone 4. 51 register_bbb_indexers() 52 wrapper = queryMultiAdapter((obj, portal), _old_IIndexableObjectWrapper) 53 if wrapper is not None: 54 w = wrapper 55 else: 56 # This is the CMF 2.2 compatible approach, which should be used going forward 57 wrapper = queryMultiAdapter((obj, catalog), IIndexableObject) 58 if wrapper is not None: 59 w = wrapper 60 return w 63 64 def getWrappedObjectNew(self, obj, portal, catalog): 65 # Returned wrapped 'obj' object with IIndexable wrapper 66 w = obj 67 if not IIndexableObject.providedBy(obj): 68 # BBB: Compatibility wrapper lookup. Should be removed in Plone 4. 69 register_bbb_indexers() 70 wrapper = queryMultiAdapter((obj, portal), _old_IIndexableObjectWrapper) 71 if wrapper is not None: 72 w = wrapper 73 else: 74 # This is the CMF 2.2 compatible approach, which should be used going forward 75 wrapper = queryMultiAdapter((obj, catalog), IIndexableObject) 76 if wrapper is not None: 77 w = wrapper 78 return w 79 80 81 def getWrappedObjectOld(self, obj, portal, catalog): 82 # Returned wrapped 'obj' object with IIndexable wrapper 83 wf = getattr(self, 'portal_workflow', None) 84 # A comment for all the frustrated developers which aren't able to pin 85 # point the code which adds the review_state to the catalog. :) 86 # The review_state var and some other workflow vars are added to the 87 # indexable object wrapper throught the code in the following lines 88 if wf is not None: 89 vars = wf.getCatalogVariablesFor(obj) 90 else: 91 vars = {} 92 93 w = getMultiAdapter((obj, portal), _old_IIndexableObjectWrapper) 94 w.update(vars) 95 96 return w 61 97 62 98 … … 73 109 schema = _catalog.schema 74 110 paths = _catalog.paths 111 getWrappedObject = IS_NEW and self.getWrappedObjectNew or self.getWrappedObjectOld 75 112 # For subtransaction support 76 113 threshold = getattr(catalog, 'threshold', 10000) … … 84 121 try: 85 122 obj = root.unrestrictedTraverse(obj_uid) 86 obj = self.getWrapedObject(obj, portal, catalog)123 obj = getWrappedObject(obj, portal, catalog) 87 124 except: 88 125 LOG.error('updateMetadata4All could not resolve '
Note: See TracChangeset
for help on using the changeset viewer.