Changeset 3151 in products


Ignore:
Timestamp:
Apr 20, 2011 8:15:52 AM (13 years ago)
Author:
vmaksymiv
Message:

pep8 fixes

Location:
quintagroup.dropdownmenu/trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/Extensions/Install.py

    r2876 r3151  
    99UNINSTALL = "profile-%s:uninstall" % PROJECT_NAME 
    1010 
     11 
    1112def uninstall(portal, reinstall=False): 
    1213    """ Uninstall this product. 
    1314 
    14         This external method is need, because portal_quickinstaller doens't know 
    15         what GenericProfile profile to apply when uninstalling a product. 
     15        This external method is need, because portal_quickinstaller doens't 
     16        know what GenericProfile profile to apply when uninstalling a product. 
    1617    """ 
    1718    setup_tool = getToolByName(portal, 'portal_setup') 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/__init__.py

    r2876 r3151  
    66PROJECT_NAME = "quintagroup.dropdownmenu" 
    77logger = logging.getLogger(PROJECT_NAME) 
    8  
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/controlpanel.py

    r2630 r3151  
    2828        conf = self._settings() 
    2929        self._overrideValue(self.widgets['show_content_tabs'], not conf[0]) 
    30         self._overrideValue(self.widgets['show_nonfolderish_tabs'], not conf[1]) 
     30        self._overrideValue(self.widgets['show_nonfolderish_tabs'], 
     31                            not conf[1]) 
    3132 
    3233    def _overrideValue(self, widget, value): 
     
    4344                                  default=term.title) 
    4445            widget.items.append({'id': id, 'name': widget.name + ':list', 
    45                 'value':term.token, 'label':label, 'checked':checked}) 
     46                'value': term.token, 'label': label, 'checked': checked}) 
    4647 
    4748    def _settings(self, folder=None, nonfolderish=None): 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/menu.py

    r1319 r3151  
    2424        if self._settings.content_tabs_level > 0: 
    2525            self.query['path']['depth'] = self._settings.content_tabs_level 
    26         elif self.query['path'].has_key('depth'): 
     26        elif 'depth' in self.query['path']: 
    2727            del self.query['path']['depth'] 
    2828 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py

    r2843 r3151  
    2424import copy 
    2525 
    26 def cache_key(a,b,c):    
     26 
     27def cache_key(a, b, c): 
    2728    return c + str(time() // (60 * 60)) 
     29 
    2830 
    2931class GlobalSectionsViewlet(common.GlobalSectionsViewlet): 
     
    3133    recurse = ViewPageTemplateFile('templates/sections_recurse.pt') 
    3234 
    33  
    3435    def update(self): 
    3536        # we may need some previously defined variables 
     
    4243        self.tool = getToolByName(context, 'portal_actions') 
    4344        self.site_url = getToolByName(context, 'portal_url')() 
    44         self.context_state = getMultiAdapter((self.context, self.request),  
     45        self.context_state = getMultiAdapter((self.context, self.request), 
    4546                                              name="plone_context_state") 
    46         self.context_url =  self.context_state.is_default_page() and \ 
     47        self.context_url = self.context_state.is_default_page() and \ 
    4748            '/'.join(self.context.absolute_url().split('/')[:-1]) or \ 
    4849            self.context.absolute_url() 
    49              
    50         self.cat_sufix  = self.conf.nested_category_sufix or '' 
     50 
     51        self.cat_sufix = self.conf.nested_category_sufix or '' 
    5152        self.cat_prefix = self.conf.nested_category_prefix or '' 
    5253        # fetch actions-based tabs? 
     
    7879        res = copy.deepcopy(res) 
    7980        self.tabs = listtabs 
    80          
     81 
    8182        # if there is no custom menu in portal tabs return 
    8283        if not listtabs: 
    8384            return [] 
    84              
     85 
    8586        current_item = -1 
    8687        delta = 1000 
    8788        for info in listtabs: 
    8889            if  self.context_url.startswith(info['url']) and \ 
    89                len(self.context_url) - len(info['url']) < delta: 
    90                delta = len(self.context_url) - len(info['url']) 
    91                current_item = listtabs.index(info) 
    92         self.id_chain = []  
    93          
     90                len(self.context_url) - len(info['url']) < delta: 
     91                delta = len(self.context_url) - len(info['url']) 
     92                current_item = listtabs.index(info) 
     93        self.id_chain = [] 
     94 
    9495        if current_item > -1 and current_item < len(listtabs) and \ 
    9596            (listtabs[current_item]['url'] != self.site_url or \ 
    96             listtabs[current_item]['url'] == self.site_url and self.context_url == self.site_url): 
    97             self.mark_active(listtabs[current_item]['id'], listtabs[current_item]['url']) 
     97            listtabs[current_item]['url'] == self.site_url and \ 
     98            self.context_url == self.site_url): 
     99 
     100            self.mark_active(listtabs[current_item]['id'], 
     101                             listtabs[current_item]['url']) 
    98102 
    99103        self._activate(res) 
    100104        return res 
    101          
     105 
    102106    @ram.cache(cache_key) 
    103107    def prepare_tabs(self, site_url): 
    104         def normalize_actions(category, object, level, parent_url = None): 
     108        def normalize_actions(category, object, level, parent_url=None): 
    105109            """walk through the tabs dictionary and build list of all tabs""" 
    106110            tabs = [] 
     
    116120                        subcat = category._getOb(subcat_id) 
    117121                        if IActionCategory.providedBy(subcat): 
    118                             children = normalize_actions(subcat, object, level+1, info['url']) 
    119  
    120                 parent_id = category['id'].replace(self.cat_prefix,'').replace(self.cat_sufix,'') 
    121                 tab = {'id' : info['id'], 
     122                            children = normalize_actions(subcat, object, 
     123                                                         level + 1, 
     124                                                         info['url']) 
     125 
     126                parent_id = category['id'].replace(self.cat_prefix, 
     127                                '').replace(self.cat_sufix, '') 
     128                tab = {'id': info['id'], 
    122129                   'title': info['title'], 
    123130                   'url': info['url'], 
    124131                   'parent': (parent_id, parent_url)} 
    125132                tabslist.append(tab) 
    126                  
    127                 tab = {'id' : info['id'], 
     133 
     134                tab = {'id': info['id'], 
    128135                       'Title': info['title'], 
    129136                       'Description': info['description'], 
     
    131138                       'show_children': len(children) > 0, 
    132139                       'children': children, 
    133                        'currentItem': False,  
     140                       'currentItem': False, 
    134141                       'currentParent': False, 
    135142                       'item_icon': {'html_tag': icon}, 
    136143                       'normalized_review_state': 'visible'} 
    137144                tabs.append(tab) 
    138             return tabs     
     145            return tabs 
    139146        tabslist = [] 
    140         tabs = normalize_actions(self.tool._getOb(self.conf.actions_category), aq_inner(self.context), 0) 
     147        tabs = normalize_actions(self.tool._getOb(self.conf.actions_category), 
     148                                 aq_inner(self.context), 0) 
    141149        return tabs, tabslist 
    142150 
     
    150158                    self._activate(info['children']) 
    151159 
    152          
    153160    def mark_active(self, current_id, url): 
    154161        for info in self.tabs: 
     
    156163                self.mark_active(info['parent'][0], info['parent'][1]) 
    157164                self.id_chain.append(info['url']) 
    158                      
    159  
    160165 
    161166    def _actionInfos(self, category, object, check_visibility=1, 
     
    222227    def is_plone_four(self): 
    223228        """Indicates if we are in plone 4. 
    224          
     229 
    225230        """ 
    226         pm = getToolByName(aq_inner(self.context), 'portal_migration')  
     231        pm = getToolByName(aq_inner(self.context), 'portal_migration') 
    227232        try: 
    228233            version = versionTupleFromString(pm.getSoftwareVersion()) 
     
    232237        if version: 
    233238            return version[0] == 4 
    234  
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/interfaces.py

    r2786 r3151  
    6767    nested_category_prefix = schema.TextLine( 
    6868        title=_(u"Nested category prefix"), 
    69         description=_(u"Prefix of category id, used to bind category with action"), 
     69        description=_(u"Prefix of category id, used to bind category " 
     70                      u"with action"), 
    7071        default=u"", 
    7172        required=False) 
     
    7374    nested_category_sufix = schema.TextLine( 
    7475        title=_(u"Nested category sufix"), 
    75         description=_(u"Sufix of category id, used to bind category with action"), 
     76        description=_(u"Sufix of category id, used to bind category " 
     77                      u"with action"), 
    7678        default=u"_sub", 
    7779        required=False) 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/setuphandlers.py

    r2876 r3151  
    2424        logger.log(logging.INFO, "Unregistered \"%s\" configlet." % conf_id) 
    2525 
     26 
    2627def cleanupRegistry(site): 
    2728    registry = queryUtility(IRegistry) 
     
    2930    delrecs = [r for r in registry.records.keys() if r.startswith(iprefix)] 
    3031    map(registry.records.__delitem__, delrecs) 
    31     logger.log(logging.INFO, "Removed %s items from plone.app.registry" % delrecs) 
     32    logger.log(logging.INFO, 
     33               "Removed %s items from plone.app.registry" % delrecs) 
     34 
    3235 
    3336def fixQIUninstallDependencies(site): 
     
    3942    if qiprod: 
    4043        utilities = getattr(qiprod, 'utilities', []) 
    41         todel = filter(lambda k:not sum(map(lambda i:PROJECT_NAME in i, k)), utilities) 
     44        todel = filter(lambda k: not sum(map( 
     45                    lambda i: PROJECT_NAME in i, k)), utilities) 
    4246        for u in todel: 
    4347            uidx = utilities.index(u) 
    4448            del utilities[uidx] 
     49 
    4550 
    4651def uninstall(context): 
     
    5459    removeConfiglet(site) 
    5560    cleanupRegistry(site) 
    56  
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/base.py

    r2875 r3151  
    2020#ptc.setupPloneSite() 
    2121 
     22 
    2223class NotInstalled(BasePTCLayer): 
    2324    """Initialize the package, without installation into portal 
     
    3031        ztc.installPackage(PROJECT_NAME) 
    3132 
     33 
    3234class Installed(BasePTCLayer): 
    3335    """ Install product into the portal 
     
    3537    def afterSetUp(self): 
    3638        self.addProduct(PROJECT_NAME) 
     39 
    3740 
    3841class UnInstalled(BasePTCLayer): 
     
    4447        try: 
    4548            qi = self.portal.portal_quickinstaller 
    46             qi.uninstallProducts(products=[PROJECT_NAME,]) 
     49            qi.uninstallProducts(products=[PROJECT_NAME, ]) 
    4750            #self._refreshSkinData() 
    4851        finally: 
    4952            setSecurityManager(sm) 
    5053 
    51 NotInstalledLayer = NotInstalled([ptc_layer,]) 
    52 InstalledLayer = Installed([NotInstalledLayer,]) 
    53 UnInstalledLayer = UnInstalled([InstalledLayer,]) 
     54NotInstalledLayer = NotInstalled([ptc_layer, ]) 
     55InstalledLayer = Installed([NotInstalledLayer, ]) 
     56UnInstalledLayer = UnInstalled([InstalledLayer, ]) 
    5457 
    5558 
    5659class TestCaseNotInstalled(ptc.PloneTestCase): 
    5760    layer = NotInstalledLayer 
     61 
    5862 
    5963class TestCase(ptc.PloneTestCase): 
     
    6569        alsoProvides(self.app.REQUEST, IDropDownMenuLayer) 
    6670 
     71 
    6772class TestCaseUnInstalled(ptc.PloneTestCase): 
    6873    layer = UnInstalledLayer 
     
    7176class FunctionalTestCaseNotInstalled(ptc.FunctionalTestCase): 
    7277    layer = NotInstalledLayer 
     78 
    7379 
    7480class FunctionalTestCase(ptc.FunctionalTestCase): 
     
    8086        alsoProvides(self.app.REQUEST, IDropDownMenuLayer) 
    8187 
     88 
    8289class FunctionalTestCaseUnInstalled(ptc.FunctionalTestCase): 
    8390    layer = UnInstalledLayer 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_controlpanel.py

    r2875 r3151  
    66 
    77from quintagroup.dropdownmenu.interfaces import IDropDownMenuSettings 
     8 
    89 
    910class RegistryTest(TestCase): 
     
    2324    def test_show_icons(self): 
    2425        # Check show_icons record 
    25         show_icons = self.registry.records[IPREFIX+'show_icons'] 
     26        show_icons = self.registry.records[IPREFIX + 'show_icons'] 
    2627 
    2728        self.failUnless('show_icons' in IDropDownMenuSettings) 
    28         self.assertEquals(self.registry[IPREFIX+'show_icons'], False) 
     29        self.assertEquals(self.registry[IPREFIX + 'show_icons'], False) 
    2930 
    3031    def test_show_content_tabs(self): 
    3132        # Check show_content_tabs record 
    32         show_content_tabs = self.registry.records[IPREFIX+'show_content_tabs'] 
     33        show_content_tabs = self.registry.records[ 
     34             IPREFIX + 'show_content_tabs'] 
    3335 
    3436        self.failUnless('show_content_tabs' in IDropDownMenuSettings) 
    35         self.assertEquals(self.registry[IPREFIX+'show_content_tabs'], True) 
     37        self.assertEquals(self.registry[IPREFIX + 'show_content_tabs'], True) 
    3638 
    3739    def test_show_nonfolderish_tabs(self): 
    3840        # Check show_nonfolderish_tabs record 
    3941        show_nonfolderish_tabs = self.registry.records[ 
    40             IPREFIX+'show_nonfolderish_tabs'] 
     42            IPREFIX + 'show_nonfolderish_tabs'] 
    4143 
    4244        self.failUnless('show_nonfolderish_tabs' in IDropDownMenuSettings) 
    43         self.assertEquals(self.registry[IPREFIX+'show_nonfolderish_tabs'], 
     45        self.assertEquals(self.registry[IPREFIX + 'show_nonfolderish_tabs'], 
    4446                          True) 
    4547 
     
    4749        # Check content_before_actions_tabs record 
    4850        content_before_actions_tabs = self.registry.records[ 
    49             IPREFIX+'content_before_actions_tabs'] 
     51            IPREFIX + 'content_before_actions_tabs'] 
    5052 
    5153        self.failUnless('content_before_actions_tabs' in IDropDownMenuSettings) 
    52         self.assertEquals(self.registry[IPREFIX+'content_before_actions_tabs'], 
    53                           False) 
     54        self.assertEquals(self.registry[ 
     55            IPREFIX + 'content_before_actions_tabs'], False) 
    5456 
    5557    def test_content_tabs_level(self): 
    5658        # Check content_tabs_level record 
    57         content_tabs_level = self.registry.records[IPREFIX+'content_tabs_level'] 
     59        content_tabs_level = self.registry.records[ 
     60            IPREFIX + 'content_tabs_level'] 
    5861 
    5962        self.failUnless('content_tabs_level' in IDropDownMenuSettings) 
    60         self.assertEquals(self.registry[IPREFIX+'content_tabs_level'], 0) 
     63        self.assertEquals(self.registry[IPREFIX + 'content_tabs_level'], 0) 
    6164 
    6265    def test_show_actions_tabs(self): 
    6366        # Check show_actions_tabs record 
    64         show_actions_tabs = self.registry.records[IPREFIX+'show_actions_tabs'] 
     67        show_actions_tabs = self.registry.records[ 
     68            IPREFIX + 'show_actions_tabs'] 
    6569 
    6670        self.failUnless('show_actions_tabs' in IDropDownMenuSettings) 
    67         self.assertEquals(self.registry[IPREFIX+'show_actions_tabs'], True) 
     71        self.assertEquals(self.registry[IPREFIX + 'show_actions_tabs'], True) 
    6872 
    6973    def test_actions_tabs_level(self): 
    7074        # Check actions_tabs_level record 
    71         actions_tabs_level = self.registry.records[IPREFIX+'actions_tabs_level'] 
     75        actions_tabs_level = self.registry.records[ 
     76            IPREFIX + 'actions_tabs_level'] 
    7277 
    7378        self.failUnless('actions_tabs_level' in IDropDownMenuSettings) 
    74         self.assertEquals(self.registry[IPREFIX+'actions_tabs_level'], 0) 
     79        self.assertEquals(self.registry[IPREFIX + 'actions_tabs_level'], 0) 
    7580 
    7681    def test_actions_category(self): 
    7782        # Check actions_category record 
    78         actions_category = self.registry.records[IPREFIX+'actions_category'] 
     83        actions_category = self.registry.records[IPREFIX + 'actions_category'] 
    7984 
    8085        self.failUnless('actions_category' in IDropDownMenuSettings) 
    81         self.assertEquals(self.registry[IPREFIX+'actions_category'], 
     86        self.assertEquals(self.registry[IPREFIX + 'actions_category'], 
    8287                          u"portal_tabs") 
    8388 
     
    8590        # Check nested_category_prefix record 
    8691        nested_category_prefix = self.registry.records[ 
    87             IPREFIX+'nested_category_prefix'] 
     92            IPREFIX + 'nested_category_prefix'] 
    8893 
    8994        self.failUnless('nested_category_prefix' in IDropDownMenuSettings) 
    90         self.assertEquals(self.registry[IPREFIX+'nested_category_prefix'], 
     95        self.assertEquals(self.registry[IPREFIX + 'nested_category_prefix'], 
    9196                          u"") 
    9297 
     
    9499        # Check nested_category_sufix record 
    95100        nested_category_sufix = self.registry.records[ 
    96             IPREFIX+'nested_category_sufix'] 
     101            IPREFIX + 'nested_category_sufix'] 
    97102 
    98103        self.failUnless('nested_category_sufix' in IDropDownMenuSettings) 
    99         self.assertEquals(self.registry[IPREFIX+'nested_category_sufix'], 
     104        self.assertEquals(self.registry[IPREFIX + 'nested_category_sufix'], 
    100105                          u"_sub") 
    101106 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_docs.py

    r2872 r3151  
    55#from zope.component import testing 
    66from base import TestCase, ztc 
     7 
    78 
    89def test_suite(): 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/tests/test_installation.py

    r2874 r3151  
    1010 
    1111from base import * 
    12 CSS_RESOURCES = ["++resource++drop_down.css",] 
    13 DEPENDENCIES = ["plone.app.registry",] 
    14 CONFIGLETS = ["dropdownmenu",] 
    15 #REGISTRY_INTERFACE = "quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings" 
     12CSS_RESOURCES = ["++resource++drop_down.css", ] 
     13DEPENDENCIES = ["plone.app.registry", ] 
     14CONFIGLETS = ["dropdownmenu", ] 
     15#REGISTRY_INTERFACE="quintagroup.dropdownmenu.interfaces.IDropDownMenuSettings" 
     16 
    1617 
    1718class TestInstallation(TestCase): 
     
    2425    def testInstalledDependencies(self): 
    2526        cp = self.portal.portal_controlpanel 
    26         configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] 
    27         self.assertTrue([1 for ai in configlets if ai=="plone.app.registry"],  
     27        configlets = [ai['id'] for ai in cp.listActionInfos( 
     28                                             check_permissions=0)] 
     29        self.assertTrue([1 for ai in configlets if ai == "plone.app.registry"], 
    2830                'Not installed required plone.app.registry product.') 
    2931 
     
    3638    def testConfiglet(self): 
    3739        cp = self.portal.portal_controlpanel 
    38         configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] 
     40        configlets = [ai['id'] for ai in cp.listActionInfos( 
     41                                             check_permissions=0)] 
    3942        for cid in CONFIGLETS: 
    40             self.assertTrue([1 for ai in configlets if ai==cid],  
     43            self.assertTrue([1 for ai in configlets if ai == cid], 
    4144                'No "%s" configlet added to plone control panel' % cid) 
    4245 
     
    4851        registry = queryUtility(IRegistry) 
    4952        afield = "show_content_tabs" 
    50         self.assertTrue(registry.records.get(IPREFIX+afield, None), 
     53        self.assertTrue(registry.records.get(IPREFIX + afield, None), 
    5154            "Not registered '%s' registry interface" % IPREFIX) 
     55 
    5256 
    5357class TestUninstallation(TestCaseUnInstalled): 
     
    6670    def testConfiglet(self): 
    6771        cp = self.portal.portal_controlpanel 
    68         configlets = [ai['id'] for ai in cp.listActionInfos(check_permissions=0)] 
     72        configlets = [ai['id'] for ai in cp.listActionInfos( 
     73                                            check_permissions=0)] 
    6974        for cid in CONFIGLETS: 
    70             self.assertFalse([1 for ai in configlets if ai==cid],  
    71                 '"%s" configlet not uninstalled from plone control panel' % cid) 
     75            self.assertFalse([1 for ai in configlets if ai == cid], 
     76                '"%s" configlet not uninstalled '\ 
     77                'from plone control panel' % cid) 
    7278 
    7379    def testBrowserLayer(self): 
     
    7884        registry = queryUtility(IRegistry) 
    7985        afield = "show_content_tabs" 
    80         self.assertFalse(registry.records.get(IPREFIX+afield, None), 
     86        self.assertFalse(registry.records.get(IPREFIX + afield, None), 
    8187            "Not unregistered '%s' registry interface" % IPREFIX) 
    8288 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/util.py

    r1319 r3151  
    1717} 
    1818 
     19 
    1920def getDropDownMenuSettings(context): 
    2021    """Return dropdown menu settings""" 
     
    2223    return DropDownMenuRecordsProxy(context, registry, IDropDownMenuSettings, 
    2324                                    omitted=()) 
     25 
    2426 
    2527class DropDownMenuRecordsProxy(RecordsProxy): 
     
    3032        # override initialization to pass context for further purposes; 
    3133        # yes, I know, this is badly to depend on context in utilities, 
    32         # but I haven't come up with some better way to proxy plone.registry yet 
    33         # skip __setattr__ 
     34        # but I haven't come up with some better way to proxy 
     35        # plone.registry yet skip __setattr__ 
    3436        self.__dict__['__context__'] = context 
    3537        super(DropDownMenuRecordsProxy, self).__init__(registry, schema, 
  • quintagroup.dropdownmenu/trunk/setup.py

    r3094 r3151  
    44version = '1.2' 
    55 
    6 tests_require=['zope.testing', 
     6tests_require = ['zope.testing', 
    77               'collective.testcaselayer'] 
    88 
     
    1212      long_description=open("README.txt").read() + "\n" + 
    1313                       open(os.path.join("docs", "HISTORY.txt")).read(), 
    14       # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers 
    1514      classifiers=[ 
    1615        "Framework :: Plone", 
     
    3433      tests_require=tests_require, 
    3534      extras_require=dict(tests=tests_require), 
    36       test_suite = 'quintagroup.dropdownmenu.tests', 
     35      test_suite='quintagroup.dropdownmenu.tests', 
    3736      entry_points=""" 
    3837      [z3c.autoinclude.plugin] 
Note: See TracChangeset for help on using the changeset viewer.