Splitted content provider class between BaseContentProvider and ViewContentProvider
--- 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,