src/pyams_utils/adapter.py
changeset 196 c0db0561ded3
parent 194 9313b3c435eb
child 197 00af28a2352d
--- a/src/pyams_utils/adapter.py	Thu Jun 14 13:57:57 2018 +0200
+++ b/src/pyams_utils/adapter.py	Thu Jun 14 17:32:18 2018 +0200
@@ -31,8 +31,9 @@
 from zope.annotation.interfaces import IAnnotations
 
 # import packages
+from pyams_utils.factory import get_object_factory
 from pyams_utils.registry import get_current_registry
-from zope.interface import implementedBy, alsoProvides
+from zope.interface import implementedBy, alsoProvides, Interface
 from zope.lifecycleevent import ObjectCreatedEvent
 from zope.location import locate as zope_locate
 
@@ -157,6 +158,9 @@
         elif factory is None:
             return None
         else:
+            if issubclass(factory, Interface):
+                factory = get_object_factory(factory)
+                assert factory is not None, "Missing object factory"
             adapter = annotations[key] = factory()
             if markers:
                 if not isinstance(markers, (list, tuple, set)):