Updated TinyMCE editor configuration lookup
authorThierry Florac <thierry.florac@onf.fr>
Thu, 27 Sep 2018 13:52:54 +0200
changeset 146 f1c96e713b54
parent 145 af78f77380e7
child 147 125071f52bfe
Updated TinyMCE editor configuration lookup
src/pyams_form/widget/__init__.py
--- a/src/pyams_form/widget/__init__.py	Thu Sep 27 13:52:33 2018 +0200
+++ b/src/pyams_form/widget/__init__.py	Thu Sep 27 13:52:54 2018 +0200
@@ -17,26 +17,10 @@
 import inspect
 import json
 import os
+
 import venusian
-
-# import interfaces
-from pyams_form.interfaces.form import IFormLayer, IResetWidget, ICloseWidget, IDateWidget, IDatetimeWidget, \
-    ITimeWidget, \
-    IColorWidget, IHTMLWidget, ISelect2Widget, ITextLineListWidget, ISEOTextLineWidget, IActionWidget
-from pyams_form.schema import IResetButton, ICloseButton, IActionButton
-from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration
-from pyams_utils.interfaces.data import IObjectData
-from pyams_utils.schema import IColorField, IHTMLField, ITextLineListField
+from pyramid.exceptions import ConfigurationError
 from pyramid.interfaces import IRequest
-from z3c.form.interfaces import INPUT_MODE, DISPLAY_MODE, IFieldWidget, IButtonAction, IWidgetLayoutTemplate, \
-    IDataConverter, NO_VALUE
-from zope.pagetemplate.interfaces import IPageTemplate
-from zope.schema.interfaces import IDate, IDatetime, ITime, IChoice, IList, ITuple, ISet
-
-# import packages
-from pyams_utils.adapter import adapter_config
-from pyams_utils.timezone import tztime, localgmtime
-from pyramid.exceptions import ConfigurationError
 from z3c.form.action import Action
 from z3c.form.browser.button import ButtonWidget
 from z3c.form.browser.select import SelectWidget
@@ -45,11 +29,25 @@
 from z3c.form.browser.textarea import TextAreaWidget
 from z3c.form.button import ButtonAction
 from z3c.form.converter import BaseDataConverter, DatetimeDataConverter as BaseDatetimeDataConverter
-from z3c.form.widget import FieldWidget, WidgetTemplateFactory, WidgetLayoutFactory
-from zope.interface import implementer, implementer_only, directlyProvides, Interface
+from z3c.form.interfaces import DISPLAY_MODE, IButtonAction, IDataConverter, IFieldWidget, INPUT_MODE, \
+    IWidgetLayoutTemplate, NO_VALUE
+from z3c.form.widget import FieldWidget, WidgetLayoutFactory, WidgetTemplateFactory
+from zope.interface import Interface, directlyProvides, implementer, implementer_only
+from zope.pagetemplate.interfaces import IPageTemplate
 from zope.schema.fieldproperty import FieldProperty
+from zope.schema.interfaces import IChoice, IDate, IDatetime, IList, ISet, ITime, ITuple
 
 from pyams_form import _
+# import interfaces
+from pyams_form.interfaces.form import IActionWidget, ICloseWidget, IColorWidget, IDateWidget, IDatetimeWidget, \
+    IFormLayer, IHTMLWidget, IResetWidget, ISEOTextLineWidget, ISelect2Widget, ITextLineListWidget, ITimeWidget
+from pyams_form.schema import IActionButton, ICloseButton, IResetButton
+from pyams_skin.interfaces.tinymce import ITinyMCEConfiguration
+# import packages
+from pyams_utils.adapter import adapter_config
+from pyams_utils.interfaces.data import IObjectData
+from pyams_utils.schema import IColorField, IHTMLField, ITextLineListField
+from pyams_utils.timezone import localgmtime, tztime
 
 
 #
@@ -354,6 +352,8 @@
     def editor_data(self):
         registry = self.request.registry
         config = registry.queryMultiAdapter((self.form, self.request), ITinyMCEConfiguration, name=self.name)
+        if (config is None) and hasattr(self, 'basename'):  # I18n widget
+            config = registry.queryMultiAdapter((self.form, self.request), ITinyMCEConfiguration, name=self.basename)
         if config is None:
             config = registry.queryMultiAdapter((self.form, self.request), ITinyMCEConfiguration)
         if config is None: