Use object factory in annotations adapters
authorThierry Florac <thierry.florac@onf.fr>
Thu, 17 Jan 2019 09:52:03 +0100
changeset 108 d5c4a83c43ed
parent 107 99eb0e812717
child 109 1753c8fc9756
Use object factory in annotations adapters
src/pyams_zmi/configuration.py
--- a/src/pyams_zmi/configuration.py	Wed Jan 16 23:40:30 2019 +0100
+++ b/src/pyams_zmi/configuration.py	Thu Jan 17 09:52:03 2019 +0100
@@ -12,25 +12,21 @@
 
 __docformat__ = 'restructuredtext'
 
+import pkg_resources
+from persistent import Persistent
+from zope.container.contained import Contained
+from zope.interface import Interface
+from zope.schema.fieldproperty import FieldProperty
 
-# import standard library
-import pkg_resources
-
-# import interfaces
+from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config, get_annotation_adapter
+from pyams_utils.factory import factory_config
 from pyams_utils.interfaces.site import ISiteRoot
 from pyams_utils.interfaces.tales import ITALESExtension
+from pyams_utils.traversing import get_parent
 from pyams_zmi.interfaces import IZMIConfiguration
 
-# import packages
-from persistent import Persistent
-from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter, get_annotation_adapter
-from pyams_utils.traversing import get_parent
-from zope.container.contained import Contained
-from zope.interface import implementer, Interface
-from zope.schema.fieldproperty import FieldProperty
 
-
-@implementer(IZMIConfiguration)
+@factory_config(IZMIConfiguration)
 class ZMIConfiguration(Persistent, Contained):
     """ZMI configuration class"""
 
@@ -90,7 +86,7 @@
 @adapter_config(context=ISiteRoot, provides=IZMIConfiguration)
 def zmi_configuration_factory(context):
     """ZMI configuration factory"""
-    return get_annotation_adapter(context, ZMI_CONFIGURATION_KEY, ZMIConfiguration,
+    return get_annotation_adapter(context, ZMI_CONFIGURATION_KEY, IZMIConfiguration,
                                   notify=False)