Ignore:
Timestamp:
Aug 22, 2012 12:40:59 PM (12 years ago)
Author:
kroman0
Message:

Pep8 fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py

    r3491 r3514  
    4343    # typically purges entries after 60 minutes. 
    4444    return view.__name__ + \ 
    45            path_key + \ 
    46            language + \ 
    47            str(time() // (60 * 5)) 
     45        path_key + \ 
     46        language + \ 
     47        str(time() // (60 * 5)) 
    4848 
    4949 
     
    5757    def func(view): 
    5858        portal_state = getMultiAdapter((view.context, view.request), 
    59                                         name=u'plone_portal_state') 
     59                                       name=u'plone_portal_state') 
    6060        # it is impossible to reliably cache entire rendered menu generated 
    6161        # with potral actions strategy. 
    6262        if not view.conf.enable_caching or view.conf.show_actions_tabs or \ 
    63            (not portal_state.anonymous() and \ 
     63            (not portal_state.anonymous() and 
    6464                view.conf.caching_strategy == 'anonymous'): 
    6565            return f(view) 
     
    9191        self.site_url = getToolByName(context, 'portal_url')() 
    9292        self.context_state = getMultiAdapter((self.context, self.request), 
    93                                               name="plone_context_state") 
     93                                             name="plone_context_state") 
    9494        self.context_url = self.context_state.is_default_page() and \ 
    9595            '/'.join(self.context.absolute_url().split('/')[:-1]) or \ 
     
    120120        conf = self.conf 
    121121        tool = self.tool 
     122        url = self.context_url 
     123        starts = url.startswith 
    122124 
    123125        # check if we have required root actions category inside tool 
     
    136138        delta = 1000 
    137139        for info in listtabs: 
    138             if  self.context_url.startswith(info['url']) and \ 
    139                 len(self.context_url) - len(info['url']) < delta: 
     140            if starts(info['url']) and len(url) - len(info['url']) < delta: 
    140141                delta = len(self.context_url) - len(info['url']) 
    141142                current_item = listtabs.index(info) 
    142143        self.id_chain = [] 
    143144 
    144         if current_item > -1 and current_item < len(listtabs) and \ 
    145             (listtabs[current_item]['url'] != self.site_url or \ 
    146             listtabs[current_item]['url'] == self.site_url and \ 
    147             self.context_url == self.site_url): 
    148  
     145        active = listtabs[current_item]['url'] == self.site_url 
     146        active = active and self.context_url == self.site_url 
     147        active = listtabs[current_item]['url'] != self.site_url or active 
     148        if  current_item > -1 and current_item < len(listtabs) and active: 
    149149            self.mark_active(listtabs[current_item]['id'], 
    150150                             listtabs[current_item]['url']) 
    151  
    152151        self._activate(res) 
    153152        return res 
     
    165164                    # try to find out appropriate subcategory 
    166165                    subcat_id = self.cat_prefix + info['id'] + self.cat_sufix 
    167                     if subcat_id != info['id'] and \ 
    168                        subcat_id in category.objectIds(): 
     166                    in_category = subcat_id in category.objectIds() 
     167                    if subcat_id != info['id'] and in_category: 
    169168                        subcat = category._getOb(subcat_id) 
    170169                        if IActionCategory.providedBy(subcat): 
     
    173172                                                         info['url']) 
    174173 
    175                 parent_id = category.getId().replace(self.cat_prefix, 
    176                                 '').replace(self.cat_sufix, '') 
     174                parent_id = category.getId() 
     175                parent_id = parent_id.replace(self.cat_prefix, '') 
     176                parent_id = parent_id.replace(self.cat_sufix, '') 
    177177                tab = {'id': info['id'], 
    178                    'title': info['title'], 
    179                    'url': info['url'], 
    180                    'parent': (parent_id, parent_url)} 
     178                       'title': info['title'], 
     179                       'url': info['url'], 
     180                       'parent': (parent_id, parent_url)} 
    181181                tabslist.append(tab) 
    182182 
     
    218218        ec = self.tool._getExprContext(object) 
    219219        actions = [ActionInfo(action, ec) for action in category.objectValues() 
    220                     if IAction.providedBy(action)] 
     220                   if IAction.providedBy(action)] 
    221221 
    222222        action_infos = [] 
Note: See TracChangeset for help on using the changeset viewer.