Changeset 3234 in products for quintagroup.dropdownmenu/trunk/quintagroup
- Timestamp:
- Jun 10, 2011 11:20:25 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py
r3153 r3234 11 11 12 12 from plone.memoize.instance import memoize 13 from plone.memoize.compress import xhtmlslimmer 13 14 from plone.app.layout.viewlets import common 14 15 from plone.app.layout.navigation.navtree import buildFolderTree … … 22 23 import copy 23 24 24 25 def cache_key(a, b, c): 26 return c + str(time() // (60 * 60)) 25 def menu_cache_key(f, view): 26 try: 27 section = view.context.getPhysicalPath()[2] 28 except: 29 section = "" 30 31 return view.__name__ + \ 32 section + \ 33 str(time() // (60 * 5)) # Every five minutes 34 # Note that the HTTP RAM-cache 35 # typically purges entries after 36 # 60 minutes. 37 38 39 def tabs_cache_key(f, view, site_url): 40 return site_url + str(time() // (60 * 60)) 27 41 28 42 … … 36 50 37 51 # prepare to gather portal tabs 38 tabs = []39 52 context = aq_inner(self.context) 40 53 self.conf = conf = self._settings() … … 49 62 self.cat_sufix = self.conf.nested_category_sufix or '' 50 63 self.cat_prefix = self.conf.nested_category_prefix or '' 64 65 @property 66 def portal_tabs(self): 67 tabs = [] 68 51 69 # fetch actions-based tabs? 52 if conf.show_actions_tabs:70 if self.conf.show_actions_tabs: 53 71 tabs.extend(self._actions_tabs()) 54 72 55 73 # fetch content structure-based tabs? 56 if conf.show_content_tabs:74 if self.conf.show_content_tabs: 57 75 # put content-based actions before content structure-based ones? 58 if conf.content_before_actions_tabs:76 if self.conf.content_before_actions_tabs: 59 77 tabs = self._content_tabs() + tabs 60 78 else: 61 79 tabs.extend(self._content_tabs()) 62 80 63 # assign collected tabs eventually 64 self.portal_tabs = tabs 81 return tabs 65 82 66 83 def _actions_tabs(self): … … 101 118 return res 102 119 103 @ram.cache( cache_key)120 @ram.cache(tabs_cache_key) 104 121 def prepare_tabs(self, site_url): 105 122 def normalize_actions(category, object, level, parent_url=None): … … 203 220 return getDropDownMenuSettings(self.context) 204 221 222 @ram.cache(menu_cache_key) 205 223 def createMenu(self): 206 return self.recurse(children=self.portal_tabs, level=1) 224 html = self.recurse(children=self.portal_tabs, level=1) 225 return xhtmlslimmer.compress(html) 207 226 208 227 def _old_update(self):
Note: See TracChangeset
for help on using the changeset viewer.