Ignore:
Timestamp:
Jan 31, 2012 12:20:31 PM (12 years ago)
Author:
chervol
Message:

pep fixes, portal_tabs cache condition added, extended readme

File:
1 edited

Legend:

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

    r3339 r3347  
    2626    # menu cache key conssits of: 
    2727    # - selected item not only top tab 
    28     # - site can beaccessed on different domains  
     28    # - site can be accessed on different domains 
    2929    # - language is important for multilingua sites 
    3030 
     
    4444           path_key + \ 
    4545           language + \ 
    46            str(time() // (60 * 5))   
    47  
    48 # we are gcaching the menu structure built out of portal_actions tool 
     46           str(time() // (60 * 5)) 
     47 
     48 
     49# we are caching the menu structure built out of portal_actions tool 
    4950# this cache key does not take in account expressions and roles settings 
    5051def tabs_cache_key(f, view, site_url): 
    5152    return site_url + str(time() // (60 * 60)) 
     53 
    5254 
    5355def dropdowncache(f): 
     
    5557        portal_state = getMultiAdapter((view.context, view.request), 
    5658                                        name=u'plone_portal_state') 
    57         # it is impossible to reliably cache entire rendered menu generated   
     59        # it is impossible to reliably cache entire rendered menu generated 
    5860        # with potral actions strategy. 
    5961        if not view.conf.enable_caching or view.conf.show_actions_tabs or \ 
     
    6567 
    6668 
     69def tabscache(f): 
     70    def func(view, site_url): 
     71        if not view.conf.enable_caching: 
     72            return f(view, site_url) 
     73        return ram.cache(tabs_cache_key)(f)(view, site_url) 
     74    return func 
     75 
     76 
    6777class GlobalSectionsViewlet(common.GlobalSectionsViewlet): 
    6878    index = ViewPageTemplateFile('templates/sections.pt') 
    6979    recurse = ViewPageTemplateFile('templates/sections_recurse.pt') 
    70  
    7180 
    7281    def update(self): 
     
    143152        return res 
    144153 
    145     @ram.cache(tabs_cache_key) 
     154    @tabscache 
    146155    def prepare_tabs(self, site_url): 
    147156        def normalize_actions(category, object, level, parent_url=None): 
Note: See TracChangeset for help on using the changeset viewer.