[Zope-Checkins] CVS: Zope3/lib/python/Interface - verify.py:1.3.136.4

Jim Fulton jim@zope.com
Mon, 4 Mar 2002 15:45:17 -0500


Update of /cvs-repository/Zope3/lib/python/Interface
In directory cvs.zope.org:/tmp/cvs-serv1376

Modified Files:
      Tag: Zope-3x-branch
	verify.py 
Log Message:
Added explicit verifyObject and verifyClass calls.


=== Zope3/lib/python/Interface/verify.py 1.3.136.3 => 1.3.136.4 ===
 import types
 
-def verify(iface, candidate, tentative=0):
+def verify(iface, candidate, tentative=0, vtype=None):
     """
 
     Verify that 'candidate' might correctly implements 'iface'.
@@ -25,7 +25,7 @@
     If optional tentative is true, suppress the "is implemented by" test.
     """
 
-    if type( candidate ) in ClassTypes:
+    if vtype is 'c' or (vtype is not 'o' and type( candidate ) in ClassTypes):
         tester = iface.isImplementedByInstancesOf
     else:
         tester = iface.isImplementedBy
@@ -55,7 +55,13 @@
             
     return 1
 
-verify_class_implementation=verify # maybe something depends on this. :(
+def verifyClass(iface, candidate, tentative=0):
+    return verify(iface, candidate, tentative, vtype='c')
+
+def verifyObject(iface, candidate, tentative=0):
+    return verify(iface, candidate, tentative, vtype='o')
+
+verify_class_implementation=verifyClass # maybe something depends on this. :(
 
 def _incompat(required, implemented):
     if (required['positional'] !=
@@ -68,10 +74,3 @@
         return "implementation doesn't support keyword arguments"
     if required['varargs'] and not implemented['varargs']:
         return "implementation doesn't support variable arguments"
-    
-        
-
-
-
-
-