Updated "factory_config" decorator so that decorated class automatically implements interface provided by factory
authorThierry Florac <thierry.florac@onf.fr>
Tue, 11 Dec 2018 09:38:24 +0100
changeset 296 eb4222d62e58
parent 295 2f480dcb3c76
child 297 7b2ec89e3898
Updated "factory_config" decorator so that decorated class automatically implements interface provided by factory
src/pyams_utils/factory.py
--- a/src/pyams_utils/factory.py	Fri Dec 07 16:10:26 2018 +0100
+++ b/src/pyams_utils/factory.py	Tue Dec 11 09:38:24 2018 +0100
@@ -64,7 +64,7 @@
 # import packages
 from pyams_utils.registry import get_global_registry
 from zope.component import adapter, queryAdapter
-from zope.interface import implementer, Interface
+from zope.interface import implementer, Interface, provider, classImplements
 from zope.interface.interface import InterfaceClass
 
 
@@ -103,6 +103,7 @@
     """
 
     class Temp(ObjectFactoryAdapter):
+        classImplements(klass, interface)
         factory = klass
 
     if_name = get_interface_name(interface)
@@ -118,7 +119,8 @@
 
     venusian = venusian
 
-    def __init__(self, **settings):
+    def __init__(self, provided, **settings):
+        settings['provided'] = provided
         self.__dict__.update(settings)
 
     def __call__(self, wrapped):