# HG changeset patch # User Thierry Florac # Date 1529912544 -7200 # Node ID b671ae6b0e88d8512d4c36f91ba7a4abcfe163ab # Parent 33c0a30554c71edd5bacab096ada433cfb3916bb Added attribute to portlet renderer to specify if portlet is using authentication information diff -r 33c0a30554c7 -r b671ae6b0e88 src/pyams_portal/interfaces/__init__.py --- a/src/pyams_portal/interfaces/__init__.py Sat Jun 23 14:32:56 2018 +0200 +++ b/src/pyams_portal/interfaces/__init__.py Mon Jun 25 09:42:24 2018 +0200 @@ -159,6 +159,7 @@ target_interface = Attribute("Target interface provided by this renderer") use_portlets_cache = Attribute("Can renderer use rendering cache?") + use_authentication = Attribute("If 'True', portlet cache entry key is based on current authentication") PORTLET_RENDERER_SETTINGS_KEY = 'pyams_portal.renderer.settings::{0}' diff -r 33c0a30554c7 -r b671ae6b0e88 src/pyams_portal/portlet.py --- a/src/pyams_portal/portlet.py Sat Jun 23 14:32:56 2018 +0200 +++ b/src/pyams_portal/portlet.py Mon Jun 25 09:42:24 2018 +0200 @@ -186,6 +186,7 @@ target_interface = None use_portlets_cache = True + use_authentication = False weight = 0 @@ -215,6 +216,8 @@ cache_key = PORTLETS_CACHE_DISPLAY_CONTEXT_KEY.format(portlet=ICacheKeyValue(self.settings), context=ICacheKeyValue(self.context), display=ICacheKeyValue(display_context)) + if self.use_authentication: + cache_key = '{0}::{1}'.format(cache_key, self.request.principal.id) # load rendered content from cache, or create output and store it in cache try: result = portlets_cache.get_value(cache_key)