# HG changeset patch # User Thierry Florac # Date 1538045645 -7200 # Node ID f1ddf2db60389bacc27d7db97b31460d76847eef # Parent 947b23a2b868532c0c5621d2b49449684e98a24d Store initial widget name in basename attribute diff -r 947b23a2b868 -r f1ddf2db6038 src/pyams_i18n/widget/__init__.py --- a/src/pyams_i18n/widget/__init__.py Tue Sep 18 16:23:28 2018 +0200 +++ b/src/pyams_i18n/widget/__init__.py Thu Sep 27 12:54:05 2018 +0200 @@ -15,26 +15,26 @@ # import standard library +from pyramid.decorator import reify +from z3c.form.browser.widget import HTMLInputWidget +from z3c.form.converter import BaseDataConverter +from z3c.form.interfaces import IDataConverter, IErrorViewSnippet, IFieldWidget, IFormAware, IValidator, NO_VALUE +from z3c.form.util import expandPrefix +from z3c.form.widget import FieldWidget, Widget +from zope.interface import alsoProvides, implementer_only +from zope.schema import ValidationError + # import interfaces from pyams_form.interfaces.form import IFormLayer +# import packages +from pyams_form.widget import SEOTextLineFieldWidget, widgettemplate_config from pyams_i18n.interfaces import II18nManager, INegotiator -from pyams_i18n.interfaces.schema import II18nField, II18nTextLineField, II18nTextField, II18nFileField, II18nHTMLField -from pyams_i18n.interfaces.widget import II18nWidget, II18nTextLineWidget, II18nTextWidget, II18nFileWidget, \ - II18nHTMLWidget, II18nSEOTextLineWidget -from z3c.form.interfaces import IDataConverter, IFieldWidget, NO_VALUE, IFormAware, IValidator, IErrorViewSnippet - -# import packages -from pyams_form.widget import widgettemplate_config, SEOTextLineFieldWidget +from pyams_i18n.interfaces.schema import II18nField, II18nFileField, II18nHTMLField, II18nTextField, II18nTextLineField +from pyams_i18n.interfaces.widget import II18nFileWidget, II18nHTMLWidget, II18nSEOTextLineWidget, II18nTextLineWidget, \ + II18nTextWidget, II18nWidget from pyams_utils.adapter import adapter_config from pyams_utils.registry import query_utility from pyams_utils.traversing import get_parent -from pyramid.decorator import reify -from z3c.form.browser.widget import HTMLInputWidget -from z3c.form.converter import BaseDataConverter -from z3c.form.util import expandPrefix -from z3c.form.widget import Widget, FieldWidget -from zope.interface import implementer_only, alsoProvides -from zope.schema import ValidationError @adapter_config(context=(II18nField, II18nWidget), provides=IDataConverter) @@ -105,9 +105,11 @@ else: widget = registry.queryMultiAdapter((self.field.value_type, self.request), IFieldWidget) if widget is not None: - prefix = expandPrefix(self.form.prefix) + expandPrefix(self.form.widgets.prefix) + expandPrefix(lang) + base_prefix = expandPrefix(self.form.prefix) + expandPrefix(self.form.widgets.prefix) + prefix = base_prefix + expandPrefix(lang) name = self.field.value_type.__name__ = self.field.__name__ widget.mode = self.mode + widget.basename = base_prefix + name widget.name = prefix + name widget.id = widget.name.replace('.', '-') if IFormAware.providedBy(self):