Updated annotations adapters
authorThierry Florac <thierry.florac@onf.fr>
Mon, 28 May 2018 14:04:17 +0200
changeset 64 a36879b2a175
parent 63 3d2cdf7911a5
child 65 a165a04015a0
Updated annotations adapters
src/pyams_i18n/property.py
--- a/src/pyams_i18n/property.py	Mon May 28 11:20:28 2018 +0200
+++ b/src/pyams_i18n/property.py	Mon May 28 14:04:17 2018 +0200
@@ -17,12 +17,12 @@
 
 # import interfaces
 from pyams_file.interfaces import DELETED_FILE, IFile, IFileInfo, IFileFieldContainer
-from zope.annotation.interfaces import IAnnotations
 from zope.schema.interfaces import IField
 
 # import packages
 from pyams_file.file import FileFactory
 from pyams_file.property import FILE_CONTAINER_ATTRIBUTES
+from pyams_utils.adapter import get_annotation_adapter
 from pyramid.threadlocal import get_current_registry
 from z3c.form.interfaces import NOT_CHANGED
 from zope.interface import alsoProvides
@@ -111,10 +111,8 @@
                     # store file attributes of instance
                     if not IFileFieldContainer.providedBy(instance):
                         alsoProvides(instance, IFileFieldContainer)
-                    annotations = IAnnotations(instance)
-                    attributes = annotations.get(FILE_CONTAINER_ATTRIBUTES)
-                    if attributes is None:
-                        attributes = annotations[FILE_CONTAINER_ATTRIBUTES] = set()
+                    attributes = get_annotation_adapter(instance, FILE_CONTAINER_ATTRIBUTES, set,
+                                                        notify=False, locate=False)
                     attributes.add('{0}::{1}'.format(self.__name, lang))
                     registry.notify(ObjectAddedEvent(new_lang_value, instance, name))
                 instance.__dict__[self.__name] = old_value