Use hostname in portlets cache key
authorThierry Florac <thierry.florac@onf.fr>
Tue, 23 Oct 2018 10:48:34 +0200
changeset 1029 4e7e71858d1c
parent 1028 3a608029647e
child 1030 8046e05b206d
Use hostname in portlets cache key
src/pyams_content/features/footer/skin/__init__.py
src/pyams_content/features/header/skin/__init__.py
--- a/src/pyams_content/features/footer/skin/__init__.py	Mon Oct 22 17:10:16 2018 +0200
+++ b/src/pyams_content/features/footer/skin/__init__.py	Tue Oct 23 10:48:34 2018 +0200
@@ -12,27 +12,23 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 import logging
 logger = logging.getLogger('PyAMS (content)')
 
-# import interfaces
-from pyams_content.features.footer.interfaces import IFooterTarget, IFooterRenderer, IFooterSettings
+from pyramid.decorator import reify
+from zope.interface import implementer
+
+from pyams_cache.beaker import get_cache
+from pyams_content.features.footer.interfaces import IFooterRenderer, IFooterSettings, IFooterTarget
 from pyams_content.features.renderer.interfaces import HIDDEN_RENDERER_NAME
+from pyams_content.features.renderer.skin import BaseContentRenderer
 from pyams_portal.interfaces import PREVIEW_MODE
+from pyams_portal.portlet import PORTLETS_CACHE_KEY, PORTLETS_CACHE_NAME, PORTLETS_CACHE_REGION
 from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.adapter import adapter_config
 from pyams_utils.interfaces import ICacheKeyValue
 from pyams_utils.interfaces.url import DISPLAY_CONTEXT
-
-# import packages
-from pyams_cache.beaker import get_cache
-from pyams_content.features.renderer.skin import BaseContentRenderer
-from pyams_portal.portlet import PORTLETS_CACHE_REGION, PORTLETS_CACHE_NAME, PORTLETS_CACHE_KEY
-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 _
 
@@ -64,6 +60,7 @@
     @reify
     def cache_key(self):
         return PORTLETS_CACHE_KEY.format(portlet=self.name,
+                                         hostname=self.request.host,
                                          context=ICacheKeyValue(self.settings_target),
                                          lang=self.request.locale_name)
 
--- a/src/pyams_content/features/header/skin/__init__.py	Mon Oct 22 17:10:16 2018 +0200
+++ b/src/pyams_content/features/header/skin/__init__.py	Tue Oct 23 10:48:34 2018 +0200
@@ -12,27 +12,23 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
 import logging
 logger = logging.getLogger('PyAMS (content)')
 
-# import interfaces
-from pyams_content.features.header.interfaces import IHeaderTarget, IHeaderRenderer, IHeaderSettings
+from pyramid.decorator import reify
+from zope.interface import implementer
+
+from pyams_cache.beaker import get_cache
+from pyams_content.features.header.interfaces import IHeaderRenderer, IHeaderSettings, IHeaderTarget
 from pyams_content.features.header.skin.interfaces import IHeaderClass
 from pyams_content.features.renderer.interfaces import HIDDEN_RENDERER_NAME
+from pyams_content.features.renderer.skin import BaseContentRenderer
 from pyams_portal.interfaces import PREVIEW_MODE
+from pyams_portal.portlet import PORTLETS_CACHE_KEY, PORTLETS_CACHE_NAME, PORTLETS_CACHE_REGION
 from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.adapter import adapter_config
 from pyams_utils.interfaces import ICacheKeyValue
-
-# import packages
-from pyams_cache.beaker import get_cache
-from pyams_content.features.renderer.skin import BaseContentRenderer
-from pyams_portal.portlet import PORTLETS_CACHE_REGION, PORTLETS_CACHE_NAME, PORTLETS_CACHE_KEY
-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 _
 
@@ -64,6 +60,7 @@
     @reify
     def cache_key(self):
         return PORTLETS_CACHE_KEY.format(portlet=self.name,
+                                         hostname=self.request.host,
                                          context=ICacheKeyValue(self.settings_target),
                                          lang=self.request.locale_name)