Added check for missing portlet renderer
authorThierry Florac <tflorac@ulthar.net>
Wed, 25 Aug 2021 17:27:31 +0200
changeset 296 6984ee473437
parent 295 9afc7f49f1fa
child 297 39267a8e8f47
Added check for missing portlet renderer
src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.mo
src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.po
src/pyams_portal/locales/pyams_portal.pot
src/pyams_portal/portlet.py
Binary file src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.mo has changed
--- a/src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.po	Wed Aug 25 14:12:34 2021 +0200
+++ b/src/pyams_portal/locales/fr/LC_MESSAGES/pyams_portal.po	Wed Aug 25 17:27:31 2021 +0200
@@ -5,7 +5,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2021-08-06 09:45+0200\n"
+"POT-Creation-Date: 2021-08-25 16:59+0200\n"
 "PO-Revision-Date: 2015-05-12 12:10+0200\n"
 "Last-Translator: Thierry Florac <tflorac@ulthar.net>\n"
 "Language-Team: French <traduc@traduc.org>\n"
@@ -20,6 +20,10 @@
 msgid "Renderer:"
 msgstr "Mode de rendu :"
 
+#: src/pyams_portal/portlet.py:182
+msgid "!! MISSING RENDERER !!"
+msgstr "!! MODE DE RENDU INCONNU !!"
+
 #: src/pyams_portal/__init__.py:46
 msgid "Manage portal templates"
 msgstr "Gérer les modèles de présentation"
--- a/src/pyams_portal/locales/pyams_portal.pot	Wed Aug 25 14:12:34 2021 +0200
+++ b/src/pyams_portal/locales/pyams_portal.pot	Wed Aug 25 17:27:31 2021 +0200
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE 1.0\n"
-"POT-Creation-Date: 2021-08-06 09:45+0200\n"
+"POT-Creation-Date: 2021-08-25 16:59+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -20,6 +20,10 @@
 msgid "Renderer:"
 msgstr ""
 
+#: ./src/pyams_portal/portlet.py:182
+msgid "!! MISSING RENDERER !!"
+msgstr ""
+
 #: ./src/pyams_portal/__init__.py:46
 msgid "Manage portal templates"
 msgstr ""
--- a/src/pyams_portal/portlet.py	Wed Aug 25 14:12:34 2021 +0200
+++ b/src/pyams_portal/portlet.py	Wed Aug 25 17:27:31 2021 +0200
@@ -176,16 +176,20 @@
         result = super(PortletPreviewer, self).render()
         renderer = self.settings.get_renderer()
         translate = self.request.localizer.translate
-        result = PREVIEW_PREFIX.format(label=translate(_("Renderer:")),
-                                       renderer=translate(renderer.label)) + result
+        result = PREVIEW_PREFIX.format(
+            label=translate(_("Renderer:")),
+            renderer=translate(renderer.label if renderer is not None
+                               else _("!! MISSING RENDERER !!"))) + result
         return result
 
 
 PORTLETS_CACHE_REGION = 'portlets'
 PORTLETS_CACHE_NAME = 'PyAMS::portlet'
 
-PORTLETS_CACHE_KEY = 'portlet::{hostname}::{portlet}::{context}::{lang}'
-PORTLETS_CACHE_DISPLAY_CONTEXT_KEY = 'portlet::{hostname}::{portlet}::{context}::{display}::{lang}'
+PORTLETS_CACHE_KEY = 'portlet::{hostname}::{portlet}:' \
+                     ':{context}::{lang}'
+PORTLETS_CACHE_DISPLAY_CONTEXT_KEY = 'portlet::{hostname}::{portlet}:' \
+                                     ':{context}::{display}::{lang}'
 
 
 @implementer(IPortletRenderer)