Added check for missing portlet
authortflorac@dagon.home
Sun, 11 Nov 2018 16:25:55 +0100
changeset 215 177de8660648
parent 214 d839b7cec93b
child 216 b991144058ba
Added check for missing portlet
src/pyams_portal/views.py
--- a/src/pyams_portal/views.py	Tue Oct 30 12:29:52 2018 +0100
+++ b/src/pyams_portal/views.py	Sun Nov 11 16:25:55 2018 +0100
@@ -65,12 +65,13 @@
         return IPortalPortletsConfiguration(self.context)
 
     def get_portlet(self, name):
-        return self.request.registry.getUtility(IPortlet, name=name)
+        return self.request.registry.queryUtility(IPortlet, name=name)
 
     def get_portlet_css_class(self, portlet_id):
         configuration = self.portlet_configuration.get_portlet_configuration(portlet_id)
         portlet = self.get_portlet(configuration.portlet_name)
-        return self.request.registry.queryMultiAdapter((portlet, self.request), IPortletCSSClass, default='')
+        if portlet is not None:
+            return self.request.registry.queryMultiAdapter((portlet, self.request), IPortletCSSClass, default='')
 
     def render_portlet(self, portlet_id):
         renderer = self.portlets.get(portlet_id)