diff -r a78ade534b97 -r d9c6b1d7fefa src/pyams_content/shared/form/field.py --- a/src/pyams_content/shared/form/field.py Fri May 25 08:05:13 2018 +0200 +++ b/src/pyams_content/shared/form/field.py Fri May 25 15:48:59 2018 +0200 @@ -20,23 +20,19 @@ from pyams_content.shared.form.interfaces import IFormFieldFactory, IFormField, IFormFieldContainer, \ IFormFieldContainerTarget, FORM_FIELD_CONTAINER_KEY from pyams_i18n.interfaces import II18n -from zope.annotation.interfaces import IAnnotations from zope.location.interfaces import ISublocations from zope.traversing.interfaces import ITraversable # import packages from persistent import Persistent -from pyams_utils.adapter import adapter_config, ContextAdapter +from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter from pyams_utils.registry import utility_config, get_global_registry from pyams_utils.request import check_request from pyams_utils.schema import MailAddressField from pyams_utils.vocabulary import vocabulary_config -from pyramid.threadlocal import get_current_registry from zope.container.contained import Contained from zope.container.ordered import OrderedContainer from zope.interface import implementer -from zope.lifecycleevent import ObjectCreatedEvent -from zope.location import locate from zope.schema import TextLine, Text, Bool, Int, Decimal, URI, Date, Choice, List from zope.schema.fieldproperty import FieldProperty from zope.componentvocabulary.vocabulary import UtilityVocabulary, UtilityTerm @@ -77,13 +73,7 @@ @adapter_config(context=IFormFieldContainerTarget, provides=IFormFieldContainer) def form_field_container_factory(context): """Form fields container factory""" - annotations = IAnnotations(context) - container = annotations.get(FORM_FIELD_CONTAINER_KEY) - if container is None: - container = annotations[FORM_FIELD_CONTAINER_KEY] = FormFieldContainer() - get_current_registry().notify(ObjectCreatedEvent(container)) - locate(container, context, '++fields++') - return container + return get_annotation_adapter(context, FORM_FIELD_CONTAINER_KEY, FormFieldContainer, name='++fields++') @adapter_config(name='fields', context=IFormFieldContainerTarget, provides=ITraversable)