Changeset 3339 in products
- Timestamp:
- Jan 26, 2012 2:50:56 PM (12 years ago)
- Location:
- quintagroup.dropdownmenu/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.dropdownmenu/trunk/docs/CONTRIBUTORS.txt
r2844 r3339 7 7 Olha Pelishok [olha] 8 8 Taras Melnychuk [fenix] 9 Malthe Borch -
quintagroup.dropdownmenu/trunk/docs/HISTORY.txt
r3287 r3339 1 1 Changelog 2 2 ========= 3 4 1.2.6 - Jan 26, 2012 5 6 * revisited caching key strategies, added language and anonymous switch 7 * added caching switch to control panel 3 8 4 9 1.2.5 - Oct 21, 2011 -
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): -
quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/interfaces.py
r3151 r3339 4 4 5 5 from plone.theme.interfaces import IDefaultPloneLayer 6 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm 6 7 7 8 from quintagroup.dropdownmenu import _ 8 9 10 cachings = SimpleVocabulary( 11 [SimpleTerm(value=u'anonymous', title=_(u'Cache only for anonymous')), 12 SimpleTerm(value=u'all', title=_(u'Cache for all users')),] 13 ) 9 14 10 15 class IDropDownMenuLayer(IDefaultPloneLayer): … … 78 83 default=u"_sub", 79 84 required=False) 85 86 enable_caching = schema.Bool( 87 title=_(u"Enable menu caching"), 88 description=_(u"Caching of the menu viewlet improves page rendering " 89 u"speed."), 90 default=True 91 ) 92 93 caching_strategy = schema.Choice( 94 title=_(u"Select caching strategy"), 95 description=_(u"Caching strategy defines how the cache key will be built."), 96 default="anonymous", 97 vocabulary=cachings 98 ) -
quintagroup.dropdownmenu/trunk/setup.py
r3287 r3339 2 2 import os 3 3 4 version = '1.2. 5'4 version = '1.2.6' 5 5 6 6 tests_require = ['zope.testing', … … 15 15 "Framework :: Plone", 16 16 "Programming Language :: Python", 17 "License :: OSI Approved :: GNU General Public License (GPL)", 18 "Operating System :: OS Independent" 17 19 "Topic :: Software Development :: Libraries :: Python Modules", 18 20 ],
Note: See TracChangeset
for help on using the changeset viewer.