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

pep8 fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  
Note: See TracChangeset for help on using the changeset viewer.