Back to index

plone3  3.1.7
cache.py
Go to the documentation of this file.
00001 from zope import component
00002 from Acquisition import aq_inner
00003 from Products.CMFCore.utils import getToolByName
00004 
00005 def get_language(context, request):
00006     portal_state = component.getMultiAdapter(
00007         (context, request), name=u'plone_portal_state')
00008     return portal_state.locale().getLocaleID()
00009 
00010 def render_cachekey(fun, self):
00011     """
00012     Generates a key based on:
00013 
00014     * Portal URL
00015     * Negotiated language
00016     * Anonymous user flag
00017     * Portlet manager
00018     * Assignment
00019     * Fingerprint of the data used by the portlet
00020     
00021     """
00022     context = aq_inner(self.context)
00023     
00024     def add(brain):
00025         path = brain.getPath().decode('ascii', 'replace')
00026         return "%s\n%s\n\n" % (path, brain.modified)
00027     fingerprint = "".join(map(add, self._data()))
00028 
00029     anonymous = getToolByName(context, 'portal_membership').isAnonymousUser()
00030 
00031     return "".join((
00032         getToolByName(aq_inner(self.context), 'portal_url')(),
00033         get_language(aq_inner(self.context), self.request),
00034         str(anonymous),
00035         self.manager.__name__,
00036         self.data.__name__,
00037         fingerprint))