--- a/src/pyams_content/component/paragraph/milestone.py Fri May 25 08:05:13 2018 +0200
+++ b/src/pyams_content/component/paragraph/milestone.py Fri May 25 15:48:59 2018 +0200
@@ -25,7 +25,6 @@
from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE, ERROR_VALUE
from pyams_form.interfaces.form import IFormContextPermissionChecker
from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
-from zope.annotation.interfaces import IAnnotations
from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
from zope.location.interfaces import ISublocations
from zope.traversing.interfaces import ITraversable
@@ -35,7 +34,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 get_current_registry, get_utility, utility_config
from pyams_utils.request import check_request
@@ -174,13 +173,7 @@
@adapter_config(context=IMilestoneContainerTarget, provides=IMilestoneContainer)
def milestone_container_factory(target):
"""Milestone container factory"""
- annotations = IAnnotations(target)
- container = annotations.get(MILESTONE_CONTAINER_KEY)
- if container is None:
- container = annotations[MILESTONE_CONTAINER_KEY] = MilestoneContainer()
- get_current_registry().notify(ObjectCreatedEvent(container))
- locate(container, target, '++milestones++')
- return container
+ return get_annotation_adapter(target, MILESTONE_CONTAINER_KEY, MilestoneContainer, name='++milestones++')
@adapter_config(name='milestones', context=IMilestoneContainerTarget, provides=ITraversable)