Changeset 1981 in products


Ignore:
Timestamp:
Mar 24, 2010 9:52:44 AM (10 years ago)
Author:
fenix
Message:

some code refactoring, made compatible with plone4

Location:
quintagroup.catalogupdater/trunk/quintagroup/catalogupdater
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/exportimport/tests/test_catalogupdate.py

    r1761 r1981  
    1515from quintagroup.catalogupdater.interfaces import ICatalogUpdater 
    1616 
     17from Products.CMFPlone.utils import getFSVersionTuple 
     18PLONEFOUR = getFSVersionTuple()[0] == 4 and True or False 
     19 
    1720_CATALOG_BODY = test_exportimport._CATALOG_BODY 
    1821_ZCTEXT_XML = test_exportimport._ZCTEXT_XML 
     
    2124<?xml version="1.0"?> 
    2225<object name="foo_catalog"> 
    23  <object name="foo_vocabulary" remove="True"/> 
     26 %s 
    2427 <index name="foo_text" remove="True"/> 
    2528 <index name="foo_text" meta_type="ZCTextIndex"> 
     
    3437 <column value="spam" update="True"/> 
    3538</object> 
    36 """ 
     39""" % (PLONEFOUR and '<object name="old_plexicon" remove="True"/>' or \ 
     40                     '<object name="foo_vocabulary" remove="True"/>') 
     41              
    3742 
    3843 
  • quintagroup.catalogupdater/trunk/quintagroup/catalogupdater/utility.py

    r1865 r1981  
    1212from Products.ZCatalog.Catalog import safe_callable 
    1313 
    14  
    1514try: 
    1615    from plone.indexer.interfaces import IIndexableObject 
    1716except ImportError: 
    18     class IIndexableObject:pass 
    1917    from plone.app.content.interfaces import IIndexableObjectWrapper \ 
    2018        as _old_IIndexableObjectWrapper 
    21     from plone.app.content.interfaces import IIndexableObjectWrapper 
    22  
    23     register_bbb_indexers = lambda:None 
    24  
    2519    IS_NEW = False 
    2620else:     
    27     from Products.CMFPlone.CatalogTool import register_bbb_indexers 
    28     from Products.CMFPlone.CatalogTool import _old_IIndexableObjectWrapper 
    29  
    3021    IS_NEW = True 
    3122 
     
    6455    def getWrappedObjectNew(self, obj, portal, catalog): 
    6556        # Returned wrapped 'obj' object with IIndexable wrapper 
    66         w = obj 
     57        wrapper = None 
    6758        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  
     59             # This is the CMF 2.2 compatible approach, which should be used going forward 
     60             wrapper = queryMultiAdapter((obj, catalog), IIndexableObject) 
     61        return wrapper and wrapper or obj 
    8062 
    8163    def getWrappedObjectOld(self, obj, portal, catalog): 
Note: See TracChangeset for help on using the changeset viewer.