--- a/src/pyams_content/features/alert/container.py Fri May 25 08:05:13 2018 +0200
+++ b/src/pyams_content/features/alert/container.py Fri May 25 15:48:59 2018 +0200
@@ -17,17 +17,14 @@
# import interfaces
from pyams_content.features.alert.interfaces import IAlertContainer, IAlertItem, IAlertTarget, ALERT_CONTAINER_KEY
-from zope.annotation.interfaces import IAnnotations
from zope.location.interfaces import ISublocations
from zope.traversing.interfaces import ITraversable
# import packages
from pyams_catalog.utils import index_object
-from pyams_utils.adapter import adapter_config, ContextAdapter
-from pyams_utils.registry import get_current_registry
+from pyams_utils.adapter import adapter_config, ContextAdapter, get_annotation_adapter
from zope.container.ordered import OrderedContainer
from zope.interface import implementer
-from zope.lifecycleevent import ObjectCreatedEvent
from zope.location import locate
@@ -55,13 +52,7 @@
@adapter_config(context=IAlertTarget, provides=IAlertContainer)
def alert_container_factory(target):
"""Alert container factory"""
- annotations = IAnnotations(target)
- container = annotations.get(ALERT_CONTAINER_KEY)
- if container is None:
- container = annotations[ALERT_CONTAINER_KEY] = AlertContainer()
- get_current_registry().notify(ObjectCreatedEvent(container))
- locate(container, target, '++alert++')
- return container
+ return get_annotation_adapter(target, ALERT_CONTAINER_KEY, AlertContainer, name='++alert++')
@adapter_config(name='alert', context=IAlertTarget, provides=ITraversable)