Changeset 3347 in products


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

pep fixes, portal_tabs cache condition added, extended readme

Location:
quintagroup.dropdownmenu/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.dropdownmenu/trunk/README.txt

    r3275 r3347  
    44This package allows to build dropdown menu through the web with portal_actions. 
    55Submenus are built from a tree of nested Category Actions and Actions. 
     6 
    67The other strategy used to populate submenus is Plone default NavigationStrategy,  
    78the one used in navigation portlet.   
     
    3738      
    3839By default the root of dropdown menu is 'portal_tabs' category. 
     40 
     41Menu caching 
     42============ 
     43 
     44If the menu built with Navigation strategy is entirely public it can be cached for 
     45all users. If Authenticaded users should see some non public items the menu can be 
     46cached for anonymous only. 
     47 
     48Caching in case of involving the portal_actions strategy is effective only in case 
     49if all the action are public and have no extra conditions. In case some conditions 
     50are applied per action switch off caching. 
     51 
    3952  
    4053Compatibility 
     
    5164* install Plone DropDown Menu in Plone via Site Setup -> Add-ons 
    5265 
    53 Find more details inside docs/INSTALL.txt  
     66Find more details on the topic inside docs/INSTALL.txt  
     67 
  • 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): 
  • quintagroup.dropdownmenu/trunk/quintagroup/dropdownmenu/interfaces.py

    r3339 r3347  
    1010cachings = SimpleVocabulary( 
    1111    [SimpleTerm(value=u'anonymous', title=_(u'Cache only for anonymous')), 
    12      SimpleTerm(value=u'all', title=_(u'Cache for all users')),] 
     12     SimpleTerm(value=u'all', title=_(u'Cache for all users')), ] 
    1313    ) 
     14 
    1415 
    1516class IDropDownMenuLayer(IDefaultPloneLayer): 
     
    8384        default=u"_sub", 
    8485        required=False) 
    85      
     86 
    8687    enable_caching = schema.Bool( 
    8788        title=_(u"Enable menu caching"), 
    8889        description=_(u"Caching of the menu viewlet improves page rendering " 
    8990                      u"speed."), 
    90         default=True         
     91        default=True 
    9192        ) 
    9293 
     
    9596    description=_(u"Caching strategy defines how the cache key will be built."), 
    9697    default="anonymous", 
    97     vocabulary=cachings         
     98    vocabulary=cachings 
    9899    ) 
Note: See TracChangeset for help on using the changeset viewer.