Splitted content provider class between BaseContentProvider and ViewContentProvider
authorThierry Florac <thierry.florac@onf.fr>
Tue, 19 Sep 2017 11:22:56 +0200
changeset 10 cbe311bfa4f2
parent 9 54b3d1afd922
child 11 85506e4365c5
Splitted content provider class between BaseContentProvider and ViewContentProvider
src/pyams_viewlet/viewlet.py
--- a/src/pyams_viewlet/viewlet.py	Wed Jun 07 10:50:54 2017 +0200
+++ b/src/pyams_viewlet/viewlet.py	Tue Sep 19 11:22:56 2017 +0200
@@ -28,15 +28,14 @@
 
 
 @implementer(IContentProvider)
-class ContentProvider(object):
-    """Template based content provider"""
+class BaseContentProvider(object):
+    """Base template based content provider"""
 
     permission = None
 
-    def __init__(self, context, request, view):
+    def __init__(self, context, request):
         self.context = context
         self.request = request
-        self.view = self.__parent__ = view
 
     def update(self):
         pass
@@ -50,6 +49,15 @@
     render = get_view_template()
 
 
+@implementer(IContentProvider)
+class ViewContentProvider(BaseContentProvider):
+    """Template based content provider"""
+
+    def __init__(self, context, request, view):
+        super(ViewContentProvider, self).__init__(context, request)
+        self.view = self.__parent__ = view
+
+
 class contentprovider_config(object):
     """Class decorator used to declare a content provider
 
@@ -81,8 +89,8 @@
 
             bases = (ob,)
             if not IContentProvider.implementedBy(ob):
-                bases = bases + (ContentProvider,)
-            new_class = type('<ContentProvider %s>' % settings.get('name'), bases, cdict)
+                bases = bases + (ViewContentProvider,)
+            new_class = type('<ViewContentProvider %s>' % settings.get('name'), bases, cdict)
 
             config = context.config.with_package(info.module)
             config.registry.registerAdapter(new_class,