Changeset 3339 in products for quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py
- Timestamp:
- Jan 26, 2012 2:50:56 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/browser/viewlets.py
r3240 r3339 23 23 import copy 24 24 25 26 25 def menu_cache_key(f, view): 26 # menu cache key conssits of: 27 # - selected item not only top tab 28 # - site can beaccessed on different domains 29 # - language is important for multilingua sites 30 27 31 portal_state = getMultiAdapter((view.context, view.request), 28 32 name=u'plone_portal_state') … … 31 35 if view.conf.content_tabs_level > 0: 32 36 content_path = content_path[:view.conf.content_tabs_level] 33 path_key = '/'.join(content_path) 37 path_key = view.request.physicalPathToURL(content_path) 38 39 language = portal_state.locale().getLocaleID() 40 41 # Cache for five minutes. Note that the HTTP RAM-cache 42 # typically purges entries after 60 minutes. 34 43 return view.__name__ + \ 35 44 path_key + \ 36 str(time() // (60 * 5)) # Every five minutes 37 # Note that the HTTP RAM-cache 38 # typically purges entries after 39 # 60 minutes. 40 41 45 language + \ 46 str(time() // (60 * 5)) 47 48 # we are gcaching the menu structure built out of portal_actions tool 49 # this cache key does not take in account expressions and roles settings 42 50 def tabs_cache_key(f, view, site_url): 43 51 return site_url + str(time() // (60 * 60)) 44 52 45 46 53 def dropdowncache(f): 47 54 def func(view): 48 if view.conf.show_actions_tabs: 55 portal_state = getMultiAdapter((view.context, view.request), 56 name=u'plone_portal_state') 57 # it is impossible to reliably cache entire rendered menu generated 58 # with potral actions strategy. 59 if not view.conf.enable_caching or view.conf.show_actions_tabs or \ 60 (not portal_state.anonymous() and \ 61 view.conf.caching_strategy == 'anonymous'): 49 62 return f(view) 50 63 return ram.cache(menu_cache_key)(f)(view) … … 55 68 index = ViewPageTemplateFile('templates/sections.pt') 56 69 recurse = ViewPageTemplateFile('templates/sections_recurse.pt') 70 57 71 58 72 def update(self):
Note: See TracChangeset
for help on using the changeset viewer.