src/pyams_content/component/paragraph/pictogram.py
changeset 558 d9c6b1d7fefa
parent 555 8e8a14452567
child 586 28445044f6e3
--- a/src/pyams_content/component/paragraph/pictogram.py	Fri May 25 08:05:13 2018 +0200
+++ b/src/pyams_content/component/paragraph/pictogram.py	Fri May 25 15:48:59 2018 +0200
@@ -26,7 +26,6 @@
 from pyams_content.reference.pictograms.interfaces import IPictogramTable
 from pyams_form.interfaces.form import IFormContextPermissionChecker
 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
-from zope.annotation import IAnnotations
 from zope.lifecycleevent import IObjectAddedEvent, ObjectModifiedEvent, ObjectCreatedEvent
 from zope.location.interfaces import ISublocations
 from zope.traversing.interfaces import ITraversable
@@ -36,7 +35,7 @@
 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphFactory, BaseParagraphContentChecker
 from pyams_content.features.checker import BaseContentChecker
 from pyams_content.features.renderer import RenderersVocabulary
-from pyams_utils.adapter import adapter_config, ContextAdapter
+from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter
 from pyams_utils.factory import factory_config
 from pyams_utils.registry import query_utility, get_current_registry, get_utility, utility_config
 from pyams_utils.request import check_request
@@ -164,13 +163,7 @@
 @adapter_config(context=IPictogramContainerTarget, provides=IPictogramContainer)
 def pictogram_container_factory(target):
     """Pictogram container factory"""
-    annotations = IAnnotations(target)
-    container = annotations.get(PICTOGRAM_CONTAINER_KEY)
-    if container is None:
-        container = annotations[PICTOGRAM_CONTAINER_KEY] = PictogramContainer()
-        get_current_registry().notify(ObjectCreatedEvent(container))
-        locate(container, target, '++pictos++')
-    return container
+    return get_annotation_adapter(target, PICTOGRAM_CONTAINER_KEY, PictogramContainer, name='++pictos++')
 
 
 @adapter_config(name='pictos', context=IPictogramContainerTarget, provides=ITraversable)