[z3-checkins] r14515 - in z3/Five/branch/Five-1.0: . tests
philikon at codespeak.net
philikon at codespeak.net
Mon Jul 11 20:54:15 CEST 2005
Author: philikon
Date: Mon Jul 11 20:54:09 2005
New Revision: 14515
Added:
z3/Five/branch/Five-1.0/tests/bridge.txt
- copied unchanged from r14513, z3/Five/trunk/tests/bridge.txt
z3/Five/branch/Five-1.0/tests/test_bridge.py
- copied unchanged from r14514, z3/Five/trunk/tests/test_bridge.py
Modified:
z3/Five/branch/Five-1.0/CHANGES.txt
z3/Five/branch/Five-1.0/bridge.py
Log:
merge yuppie's r14504 from the trunk:
- fixed tests for Method objects and added tests for bases
- fixed fromZ2Interface and added fromZ2Method to make the tests pass
Modified: z3/Five/branch/Five-1.0/CHANGES.txt
==============================================================================
--- z3/Five/branch/Five-1.0/CHANGES.txt (original)
+++ z3/Five/branch/Five-1.0/CHANGES.txt Mon Jul 11 20:54:09 2005
@@ -2,6 +2,12 @@
Five Changes
============
+Five 1.0.2 (2005-07-12)
+=======================
+
+* Fixed some issues with bridged interfaces: Bases and Methods were not
+ bridged correctly. extends() was never True.
+
Five 1.0.1 (2005-05-31)
=======================
Modified: z3/Five/branch/Five-1.0/bridge.py
==============================================================================
--- z3/Five/branch/Five-1.0/bridge.py (original)
+++ z3/Five/branch/Five-1.0/bridge.py Mon Jul 11 20:54:09 2005
@@ -18,13 +18,16 @@
from Interface._InterfaceClass import Interface as Z2_InterfaceClass
from Interface import Interface as Z2_Interface
from Interface import Attribute as Z2_Attribute
+from Interface.Method import Method as Z2_Method
from zope.interface.interface import InterfaceClass as Z3_InterfaceClass
from zope.interface.interface import Interface as Z3_Interface
from zope.interface.interface import Attribute as Z3_Attribute
+from zope.interface.interface import Method as Z3_Method
-def fromZ2Interface(z2i):
+_bridges = {Z2_Interface: Z3_Interface}
+def fromZ2Interface(z2i):
""" Return a Zope 3 interface corresponding to 'z2i'.
o 'z2i' must be a Zope 2 interface.
@@ -32,8 +35,8 @@
if not isinstance(z2i, Z2_InterfaceClass):
raise ValueError, 'Not a Zope 2 interface!'
- if z2i is Z2_Interface: # special case; root in new hierarchy!
- return Z3_Interface
+ if z2i in _bridges:
+ return _bridges[z2i]
name = z2i.getName()
@@ -42,23 +45,25 @@
attrs = {}
for k, v in z2i.namesAndDescriptions():
+ if isinstance(v, Z2_Method):
+ v = fromZ2Method(v)
- if isinstance(v, Z2_Attribute):
+ elif isinstance(v, Z2_Attribute):
v = fromZ2Attribute(v)
attrs[k] = v
# XXX: Note that we pass the original interface's __module__;
# we may live to regret that.
- return Z3_InterfaceClass(name=name,
- bases=bases,
- attrs=attrs,
- __doc__=z2i.getDoc(),
- __module__=z2i.__module__,
- )
+ z3i = Z3_InterfaceClass(name=name,
+ bases=tuple(bases),
+ attrs=attrs,
+ __doc__=z2i.getDoc(),
+ __module__=z2i.__module__)
+ _bridges[z2i] = z3i
+ return z3i
def fromZ2Attribute(z2a):
-
""" Return a Zope 3 interface attribute corresponding to 'z2a'.
o 'z2a' must be a Zope 2 interface attribute.
@@ -67,3 +72,20 @@
raise ValueError, 'Not a Zope 2 interface attribute!'
return Z3_Attribute(z2a.getName(), z2a.getDoc())
+
+def fromZ2Method(z2m):
+ """ Return a Zope 3 interface method corresponding to 'z2m'.
+
+ o 'z2m' must be a Zope 2 interface method.
+ """
+ if not isinstance(z2m, Z2_Method):
+ raise ValueError, 'Not a Zope 2 interface method!'
+
+ z3m = Z3_Method(z2m.getName(), z2m.getDoc())
+ sig = z2m.getSignatureInfo()
+ z3m.positional = sig['positional']
+ z3m.required = sig['required']
+ z3m.optional = sig['optional']
+ z3m.varargs = sig['varargs']
+ z3m.kwargs = sig['kwargs']
+ return z3m
More information about the z3-checkins
mailing list