Check if adapter factory is a class
authorThierry Florac <thierry.florac@onf.fr>
Fri, 15 Jun 2018 10:59:13 +0200
changeset 197 00af28a2352d
parent 196 c0db0561ded3
child 198 7d70896756f2
child 267 6d2469d780f7
Check if adapter factory is a class
src/pyams_utils/adapter.py
--- a/src/pyams_utils/adapter.py	Thu Jun 14 17:32:18 2018 +0200
+++ b/src/pyams_utils/adapter.py	Fri Jun 15 10:59:13 2018 +0200
@@ -27,6 +27,8 @@
 
 import venusian
 
+from inspect import isclass
+
 # import interfaces
 from zope.annotation.interfaces import IAnnotations
 
@@ -158,7 +160,7 @@
         elif factory is None:
             return None
         else:
-            if issubclass(factory, Interface):
+            if isclass(factory) and issubclass(factory, Interface):
                 factory = get_object_factory(factory)
                 assert factory is not None, "Missing object factory"
             adapter = annotations[key] = factory()