src/pyams_content/features/footer/skin/__init__.py
changeset 868 1fcd5c845d1d
parent 865 bddcf038737f
child 1029 4e7e71858d1c
--- a/src/pyams_content/features/footer/skin/__init__.py	Thu Jul 19 17:19:50 2018 +0200
+++ b/src/pyams_content/features/footer/skin/__init__.py	Thu Jul 19 22:15:29 2018 +0200
@@ -32,13 +32,18 @@
 from pyams_utils.adapter import adapter_config
 from pyams_utils.traversing import get_parent
 from pyramid.decorator import reify
+from zope.interface import implementer
 
 from pyams_content import _
 
 
+@implementer(IFooterRenderer)
 class BaseFooterRenderer(BaseContentRenderer):
     """Base footer renderer"""
 
+    name = None
+    settings_key = None
+
     @reify
     def settings_target(self):
         context = self.request.annotations.get(DISPLAY_CONTEXT)
@@ -56,24 +61,28 @@
             settings = IFooterSettings(settings.parent)
         return settings.settings
 
+    @reify
+    def cache_key(self):
+        return PORTLETS_CACHE_KEY.format(portlet=self.name,
+                                         context=ICacheKeyValue(self.settings_target),
+                                         lang=self.request.locale_name)
+
     def render(self):
         preview_mode = self.request.annotations.get(PREVIEW_MODE, False)
         if preview_mode:
             return super(BaseFooterRenderer, self).render()
         else:
             portlets_cache = get_cache(PORTLETS_CACHE_REGION, PORTLETS_CACHE_NAME)
-            cache_key = PORTLETS_CACHE_KEY.format(portlet=self.name,
-                                                  context=ICacheKeyValue(self.settings_target),
-                                                  lang=self.request.locale_name)
+            cache_key = self.cache_key
             if self.context is not self.request.context:  # display shared content
                 cache_key = '{0}::shared'.format(cache_key)
             try:
                 result = portlets_cache.get_value(cache_key)
-                logger.debug("Retrieving header content from cache key {0}".format(cache_key))
+                logger.debug("Retrieving footer content from cache key {0}".format(cache_key))
             except KeyError:
                 result = super(BaseFooterRenderer, self).render()
                 portlets_cache.set_value(cache_key, result)
-                logger.debug("Storing header content for cache key {0}".format(cache_key))
+                logger.debug("Storing footer content to cache key {0}".format(cache_key))
             return result