# HG changeset patch # User Thierry Florac # Date 1532175953 -7200 # Node ID aa7f59770245ef129f66e63d2c89c74782f94154 # Parent f9449f82e6a0eb45eecaa6fbea2715cf9c986659 Added method to get portlet from configation diff -r f9449f82e6a0 -r aa7f59770245 src/pyams_portal/interfaces/__init__.py --- a/src/pyams_portal/interfaces/__init__.py Fri Jul 20 12:52:19 2018 +0200 +++ b/src/pyams_portal/interfaces/__init__.py Sat Jul 21 14:25:53 2018 +0200 @@ -109,6 +109,9 @@ portlet_name = Attribute("Portlet name") + def get_portlet(self): + """Return portlet utility matching current portlet name""" + can_inherit = Attribute("Can inherit parent configuration?") parent = Attribute("Portlet configuration parent") diff -r f9449f82e6a0 -r aa7f59770245 src/pyams_portal/portlet.py --- a/src/pyams_portal/portlet.py Fri Jul 20 12:52:19 2018 +0200 +++ b/src/pyams_portal/portlet.py Sat Jul 21 14:25:53 2018 +0200 @@ -35,6 +35,7 @@ from pyams_cache.beaker import get_cache from pyams_utils.adapter import adapter_config, ContextAdapter, get_adapter_weight, get_annotation_adapter from pyams_utils.factory import get_object_factory, is_interface +from pyams_utils.registry import get_global_registry from pyams_utils.request import check_request from pyams_utils.vocabulary import vocabulary_config from pyams_viewlet.viewlet import ViewContentProvider @@ -358,6 +359,9 @@ settings.configuration = self self._settings = settings + def get_portlet(self): + return get_global_registry().queryUtility(IPortlet, name=self.portlet_name) + @property def can_inherit(self): return not IPortalTemplate.providedBy(self.__parent__)