[Zope3-checkins] SVN: Zope3/trunk/ Fixed bug 402,
http://www.zope.org/Collectors/Zope3-dev/402
Jim Fulton
jim at zope.com
Sun Nov 13 12:11:09 EST 2005
Log message for revision 40082:
Fixed bug 402, http://www.zope.org/Collectors/Zope3-dev/402
classImplements after classImplementsOnly lost the interfaces declated
in classImplementsOnly.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/zope/interface/declarations.py
U Zope3/trunk/src/zope/interface/tests/test_declarations.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2005-11-13 13:41:57 UTC (rev 40081)
+++ Zope3/trunk/doc/CHANGES.txt 2005-11-13 17:11:09 UTC (rev 40082)
@@ -154,6 +154,10 @@
Bug Fixes
+ - Fixed bug 402, http://www.zope.org/Collectors/Zope3-dev/402
+ classImplements after classImplementsOnly lost the interfaces
+ declated in classImplementsOnly.
+
- Fixed bug 396, http://www.zope.org/Collectors/Zope3-dev/396.
When doing multi-adapter lookups, the interface of the first
object wan't given adequate weight.
Modified: Zope3/trunk/src/zope/interface/declarations.py
===================================================================
--- Zope3/trunk/src/zope/interface/declarations.py 2005-11-13 13:41:57 UTC (rev 40081)
+++ Zope3/trunk/src/zope/interface/declarations.py 2005-11-13 17:11:09 UTC (rev 40082)
@@ -258,8 +258,13 @@
# These specify interfaces implemented by instances of classes
class Implements(Declaration):
+
+ # class whose specification should be used as additional base
inherit = None
+
+ # interfaces actually declared for a class
declared = ()
+
__name__ = '?'
def __repr__(self):
@@ -410,8 +415,9 @@
whatever interfaces instances of ``A`` and ``B`` implement.
"""
spec = implementedBy(cls)
- spec.__bases__ = tuple(_normalizeargs(interfaces))
+ spec.declared = ()
spec.inherit = None
+ classImplements(cls, *interfaces)
def classImplements(cls, *interfaces):
"""Declare additional interfaces implemented for instances of a class
Modified: Zope3/trunk/src/zope/interface/tests/test_declarations.py
===================================================================
--- Zope3/trunk/src/zope/interface/tests/test_declarations.py 2005-11-13 13:41:57 UTC (rev 40081)
+++ Zope3/trunk/src/zope/interface/tests/test_declarations.py 2005-11-13 17:11:09 UTC (rev 40082)
@@ -358,6 +358,38 @@
True
"""
+def test_classImplements_after_classImplementsOnly_issue_402():
+ """http://www.zope.org/Collectors/Zope3-dev/402
+
+>>> from zope.interface import *
+>>> class I1(Interface):
+... pass
+>>> class I2(Interface):
+... pass
+>>> class C:
+... implements(I1)
+>>> class C2:
+... implementsOnly(I2)
+>>> class I3(Interface):
+... pass
+
+>>> [i.__name__ for i in providedBy(C2()).__iro__]
+['I2', 'Interface']
+
+>>> classImplements(C2, I3)
+>>> [i.__name__ for i in providedBy(C2()).__iro__]
+['I2', 'I3', 'Interface']
+
+>>> class I4(Interface):
+... pass
+>>> classImplements(C2, I4)
+>>> [i.__name__ for i in providedBy(C2()).__iro__]
+['I2', 'I3', 'I4', 'Interface']
+
+
+"""
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Test))
More information about the Zope3-Checkins
mailing list