Updated annotations adapters
authorThierry Florac <thierry.florac@onf.fr>
Mon, 28 May 2018 14:05:56 +0200
changeset 43 c348a83243fc
parent 42 db08fdf0afc5
child 44 23424132a850
Updated annotations adapters
src/pyams_sequence/sequence.py
--- a/src/pyams_sequence/sequence.py	Mon May 28 12:16:30 2018 +0200
+++ b/src/pyams_sequence/sequence.py	Mon May 28 14:05:56 2018 +0200
@@ -17,11 +17,10 @@
 
 # import interfaces
 from pyams_sequence.interfaces import ISequentialIdInfo, ISequentialIdTarget, ISequentialIntIds
-from zope.annotation.interfaces import IAnnotations
 
 # import packages
 from persistent import Persistent
-from pyams_utils.adapter import adapter_config
+from pyams_utils.adapter import adapter_config, get_annotation_adapter
 from pyams_utils.registry import get_utility
 from zope.interface import implementer
 from zope.schema.fieldproperty import FieldProperty
@@ -53,8 +52,5 @@
 @adapter_config(context=ISequentialIdTarget, provides=ISequentialIdInfo)
 def sequential_id_info_factory(context):
     """Sequential ID info factory"""
-    annotations = IAnnotations(context)
-    info = annotations.get(SEQUENCE_INFO_KEY)
-    if info is None:
-        info = annotations[SEQUENCE_INFO_KEY] = SequentialIdInfo()
-    return info
+    return get_annotation_adapter(context, SEQUENCE_INFO_KEY, SequentialIdInfo,
+                                  notify=False, locate=False)