Moved attributes definition to base renderer
authorThierry Florac <thierry.florac@onf.fr>
Fri, 02 Mar 2018 16:39:28 +0100
changeset 434 a1c31d22e042
parent 433 76a597a42c19
child 435 ce4ae073a7f7
Moved attributes definition to base renderer
src/pyams_content/features/renderer/zmi/__init__.py
--- a/src/pyams_content/features/renderer/zmi/__init__.py	Fri Mar 02 15:35:45 2018 +0100
+++ b/src/pyams_content/features/renderer/zmi/__init__.py	Fri Mar 02 16:39:28 2018 +0100
@@ -43,8 +43,6 @@
     """Base renderer preview"""
 
     language = None
-    context_attrs = ()
-    i18n_context_attrs = ()
 
     def __init__(self, context, request):
         super(BaseRenderedContentPreview, self).__init__(context, request)
@@ -54,13 +52,6 @@
         renderer = self.renderer
         if renderer is not None:
             renderer.language = self.language
-            for attr in self.context_attrs:
-                setattr(renderer, attr, getattr(self.context, attr, None))
-            if self.i18n_context_attrs:
-                i18n = II18n(self.context, None)
-                if i18n is not None:
-                    for attr in self.i18n_context_attrs:
-                        setattr(renderer, attr, i18n.get_attribute(attr, lang=self.language, request=self.request))
             renderer.update()
 
     def render(self):
@@ -81,6 +72,10 @@
     weight = 0
     settings_interface = None
 
+    language = None
+    context_attrs = ()
+    i18n_context_attrs = ()
+
     @property
     def settings(self):
         if self.settings_interface is None:
@@ -88,7 +83,13 @@
         return IRendererSettings(self.context)
 
     def update(self):
-        pass
+        for attr in self.context_attrs:
+            setattr(self, attr, getattr(self.context, attr, None))
+        if self.i18n_context_attrs:
+            i18n = II18n(self.context, None)
+            if i18n is not None:
+                for attr in self.i18n_context_attrs:
+                    setattr(self, attr, i18n.get_attribute(attr, lang=self.language, request=self.request))
 
     render = get_view_template()