Changeset 3514 in products for quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py
- Timestamp:
- Aug 22, 2012 12:40:59 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py
r3491 r3514 43 43 # typically purges entries after 60 minutes. 44 44 return view.__name__ + \ 45 46 47 45 path_key + \ 46 language + \ 47 str(time() // (60 * 5)) 48 48 49 49 … … 57 57 def func(view): 58 58 portal_state = getMultiAdapter((view.context, view.request), 59 59 name=u'plone_portal_state') 60 60 # it is impossible to reliably cache entire rendered menu generated 61 61 # with potral actions strategy. 62 62 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 64 64 view.conf.caching_strategy == 'anonymous'): 65 65 return f(view) … … 91 91 self.site_url = getToolByName(context, 'portal_url')() 92 92 self.context_state = getMultiAdapter((self.context, self.request), 93 93 name="plone_context_state") 94 94 self.context_url = self.context_state.is_default_page() and \ 95 95 '/'.join(self.context.absolute_url().split('/')[:-1]) or \ … … 120 120 conf = self.conf 121 121 tool = self.tool 122 url = self.context_url 123 starts = url.startswith 122 124 123 125 # check if we have required root actions category inside tool … … 136 138 delta = 1000 137 139 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: 140 141 delta = len(self.context_url) - len(info['url']) 141 142 current_item = listtabs.index(info) 142 143 self.id_chain = [] 143 144 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: 149 149 self.mark_active(listtabs[current_item]['id'], 150 150 listtabs[current_item]['url']) 151 152 151 self._activate(res) 153 152 return res … … 165 164 # try to find out appropriate subcategory 166 165 subcat_id = self.cat_prefix + info['id'] + self.cat_sufix 167 i f 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: 169 168 subcat = category._getOb(subcat_id) 170 169 if IActionCategory.providedBy(subcat): … … 173 172 info['url']) 174 173 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, '') 177 177 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)} 181 181 tabslist.append(tab) 182 182 … … 218 218 ec = self.tool._getExprContext(object) 219 219 actions = [ActionInfo(action, ec) for action in category.objectValues() 220 220 if IAction.providedBy(action)] 221 221 222 222 action_infos = []
Note: See TracChangeset
for help on using the changeset viewer.