Changeset 3563 in products


Ignore:
Timestamp:
Sep 24, 2012 11:24:32 AM (7 years ago)
Author:
potar
Message:

added compatibility with Plone 4.3; added utils for work with viewlets

Location:
quintagroup.plonetabs/trunk/quintagroup/plonetabs
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py

    r3437 r3563  
    77from zope.interface import implements 
    88from zope.component import getMultiAdapter 
    9 from zope.app.container.interfaces import INameChooser 
     9 
     10# BBB: compatibility with older plone versions 
     11try: 
     12     # Plone < 4.3 
     13     from zope.app.container import interfaces 
     14     INameChooser = interfaces.INameChooser 
     15except ImportError: 
     16     # Plone >= 4.3  
     17     from zope.container.interfaces import INameChooser 
     18      
    1019from zope.viewlet.interfaces import IViewletManager, IViewlet 
    1120 
     
    2534 
    2635from quintagroup.plonetabs.config import PROPERTY_SHEET, FIELD_NAME 
     36from quintagroup.plonetabs.utils import setupViewletByName 
    2737from quintagroup.plonetabs import messageFactory as _ 
    2838from interfaces import IPloneTabsControlPanel 
     
    444454    def selected_portal_tab(self): 
    445455        """See global-sections viewlet""" 
    446         selectedTabs = self.context.restrictedTraverse('selectedTabs') 
    447         selected_tabs = selectedTabs('index_html', self.context, 
    448             self.portal_tabs()) 
     456        # BBB: compatibility with older plone versions. 
     457        # ``selectedTabs`` Python script was merged into the  
     458        # GlobalSectionsViewlet. 
     459        section_viewlet = setupViewletByName(self, 
     460                                             self.context, 
     461                                             self.request, 
     462                                             'plone.global_sections') 
     463        if section_viewlet: 
     464            # Plone >= 4.3 
     465            selected_tabs = section_viewlet.selectedTabs( 
     466                default_tab='index_html',  
     467                portal_tabs=self.portal_tabs()) 
     468        else: 
     469            # Plone < 4.3 
     470            selectedTabs = self.context.restrictedTraverse('selectedTabs') 
     471            selected_tabs = selectedTabs('index_html', self.context, 
     472                self.portal_tabs()) 
    449473 
    450474        return selected_tabs['portal'] 
  • quintagroup.plonetabs/trunk/quintagroup/plonetabs/tests/test_erase.py

    r3437 r3563  
    66from Testing import ZopeTestCase as ztc 
    77 
    8 from zope.app.component.hooks import setHooks, setSite 
     8# BBB: compatibility with older plone versions 
     9try: 
     10    # Plone < 4.3 
     11    from zope.app.component import hooks  
     12    setSite = hooks.setSite 
     13    setHooks = hooks.setHooks 
     14except ImportError: 
     15    # Plone >= 4.3  
     16    from zope.component.hooks import setSite, setHooks 
    917 
    1018from plone.browserlayer.utils import registered_layers 
Note: See TracChangeset for help on using the changeset viewer.