Ignore:
Timestamp:
Jun 20, 2011 1:52:31 PM (13 years ago)
Author:
kroman0
Message:

Fixed caching menu

File:
1 edited

Legend:

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

    r3236 r3239  
    2525 
    2626def menu_cache_key(f, view): 
    27     try: 
    28         section = view.context.getPhysicalPath()[2] 
    29     except: 
    30         section = "" 
    31  
     27    portal_state = getMultiAdapter((view.context, view.request), 
     28                                   name=u'plone_portal_state') 
     29    site_len = len(portal_state.navigation_root_path().split('/')) 
     30    content_path = view.context.getPhysicalPath()[site_len:] 
     31    if view.conf.content_tabs_level > 0: 
     32        content_path = content_path[:view.conf.content_tabs_level] 
     33    path_key = '/'.join(content_path) 
    3234    return view.__name__ + \ 
    33            section + \ 
     35           path_key + \ 
    3436           str(time() // (60 * 5))  # Every five minutes 
    3537                                    # Note that the HTTP RAM-cache 
     
    3739                                    # 60 minutes. 
    3840 
    39  
    4041def tabs_cache_key(f, view, site_url): 
    4142    return site_url + str(time() // (60 * 60)) 
     43 
     44def dropdowncache(f): 
     45    def func(view): 
     46        if view.conf.show_actions_tabs: 
     47            return f(view) 
     48        return ram.cache(menu_cache_key)(f)(view) 
     49    return func 
    4250 
    4351 
     
    221229        return getDropDownMenuSettings(self.context) 
    222230 
    223     @ram.cache(menu_cache_key) 
     231    @dropdowncache 
    224232    def createMenu(self): 
    225233        html = self.recurse(children=self.portal_tabs, level=1) 
Note: See TracChangeset for help on using the changeset viewer.