Clear portlets cache on any portlet modification
authorThierry Florac <thierry.florac@onf.fr>
Thu, 21 Jun 2018 16:38:12 +0200
changeset 134 1cee610aecce
parent 133 7ad82c70e528
child 135 3bca72c8574d
Clear portlets cache on any portlet modification
src/pyams_portal/zmi/layout.py
--- a/src/pyams_portal/zmi/layout.py	Thu Jun 21 16:37:36 2018 +0200
+++ b/src/pyams_portal/zmi/layout.py	Thu Jun 21 16:38:12 2018 +0200
@@ -9,6 +9,8 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_cache.beaker import get_cache
+from pyams_portal.portlet import PORTLETS_CACHE_REGION, PORTLETS_CACHE_NAME
 
 __docformat__ = 'restructuredtext'
 
@@ -503,6 +505,11 @@
         if editor is None:
             raise NotFound()
         changes = editor()
+        # clear portlets cache on settings update
+        if changes:
+            portlets_cache = get_cache(PORTLETS_CACHE_REGION, PORTLETS_CACHE_NAME)
+            portlets_cache.clear()
+        # get edit output
         translate = self.request.localizer.translate
         if changed_override or changes:
             # we commit before loading previewer to avoid BLOBs "uncommitted changes" error