Added resources management to BaseContentProvider class
authorThierry Florac <tflorac@ulthar.net>
Thu, 27 Dec 2018 16:27:38 +0100
changeset 38 e0742533e8b2
parent 37 38ec13042956
child 39 7be246c69448
Added resources management to BaseContentProvider class
src/pyams_viewlet/viewlet.py
--- a/src/pyams_viewlet/viewlet.py	Fri Dec 07 14:23:26 2018 +0100
+++ b/src/pyams_viewlet/viewlet.py	Thu Dec 27 16:27:38 2018 +0100
@@ -12,22 +12,19 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard packages
 import logging
-logger = logging.getLogger('PyAMS (viewlet)')
 
 import venusian
-
-# import interfaces
-from pyams_viewlet.interfaces import IViewlet, IViewletManager
+from pyramid.exceptions import ConfigurationError
 from pyramid.interfaces import IRequest, IView
 from zope.contentprovider.interfaces import IContentProvider
+from zope.interface import Interface, implementer
 
-# import packages
 from pyams_template.template import get_view_template
-from pyramid.exceptions import ConfigurationError
-from zope.interface import implementer, Interface
+from pyams_viewlet.interfaces import IViewlet, IViewletManager
+
+
+logger = logging.getLogger('PyAMS (viewlet)')
 
 
 @implementer(IContentProvider)
@@ -56,6 +53,12 @@
 class BaseContentProvider(EmptyContentProvider):
     """Base template based content provider"""
 
+    resources = ()
+
+    def update(self):
+        for resource in self.resources:
+            resource.need()
+
     render = get_view_template()