Use object factory in annotations adapters
authorThierry Florac <thierry.florac@onf.fr>
Thu, 17 Jan 2019 10:50:47 +0100
changeset 65 cc7c2b11ab27
parent 64 cb064f40c79d
child 66 533f7e7ce187
Use object factory in annotations adapters
src/pyams_gis/configuration.py
--- a/src/pyams_gis/configuration.py	Tue Oct 23 12:23:07 2018 +0200
+++ b/src/pyams_gis/configuration.py	Thu Jan 17 10:50:47 2019 +0100
@@ -12,21 +12,16 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
-
-# import interfaces
-from pyams_gis.interfaces.configuration import IMapConfiguration, IMapConfigurationTarget
-
-# import packages
 from persistent import Persistent
-from pyams_utils.adapter import adapter_config, get_annotation_adapter
 from zope.container.contained import Contained
-from zope.interface import implementer
 from zope.schema.fieldproperty import FieldProperty
 
+from pyams_gis.interfaces.configuration import IMapConfiguration, IMapConfigurationTarget
+from pyams_utils.adapter import adapter_config, get_annotation_adapter
+from pyams_utils.factory import factory_config
 
-@implementer(IMapConfiguration)
+
+@factory_config(IMapConfiguration)
 class MapConfiguration(Persistent, Contained):
     """Map configuration persistent class"""
 
@@ -82,4 +77,4 @@
 @adapter_config(context=IMapConfigurationTarget, provides=IMapConfiguration)
 def map_configuration_factory(context):
     """Map configuration factory"""
-    return get_annotation_adapter(context, MAP_CONFIGURATION_KEY, MapConfiguration)
+    return get_annotation_adapter(context, MAP_CONFIGURATION_KEY, IMapConfiguration)