[Checkins] SVN: Zope3/branches/3.3/src/zope/app/interface/ Fix
interfaces that subclass interfaces in persistent modules
Ross Patterson
me at rpatterson.net
Mon Feb 5 16:33:27 EST 2007
Log message for revision 72381:
Fix interfaces that subclass interfaces in persistent modules
When interfaces in a persistent module subclass other interfaces from
a persistent module, they then become dependents of the subclassed
interface. As such the DependentsDict needs to convert such
interfaces to thier persistent versions.
I added InterfaceClass to the values handled by the DependentsDict and
updated the tests.
Changed:
U Zope3/branches/3.3/src/zope/app/interface/__init__.py
U Zope3/branches/3.3/src/zope/app/interface/tests/test_interface.py
-=-
Modified: Zope3/branches/3.3/src/zope/app/interface/__init__.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/interface/__init__.py 2007-02-05 20:31:23 UTC (rev 72380)
+++ Zope3/branches/3.3/src/zope/app/interface/__init__.py 2007-02-05 21:33:26 UTC (rev 72381)
@@ -110,6 +110,11 @@
PersistentInterface = PersistentInterfaceClass("PersistentInterface",
(Interface, ))
+
+def persistentInterface(iface):
+ return PersistentInterfaceClass(iface.__name__)
+persistentFactories[InterfaceClass] = persistentInterface
+
class PersistentInterfaceWrapper(Wrapper):
def unwrap(self):
Modified: Zope3/branches/3.3/src/zope/app/interface/tests/test_interface.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/interface/tests/test_interface.py 2007-02-05 20:31:23 UTC (rev 72380)
+++ Zope3/branches/3.3/src/zope/app/interface/tests/test_interface.py 2007-02-05 21:33:26 UTC (rev 72381)
@@ -46,10 +46,16 @@
aFoo = Foo()
"""
+class IQuux(Interface): pass
+
bar_code = """\
from zope.interface import Interface
+from zope.app.interface.tests.test_interface import IQuux
+
class IBar(Interface): pass
+class IBah(IQuux): pass
class IBaz(Interface): pass
+class IBlah(IBaz): pass
"""
class Bar(Persistent): pass
@@ -98,18 +104,36 @@
self.registry.newModule("barmodule", bar_code)
barmodule = self.registry.findModule("barmodule")
+
bar = Bar()
directlyProvides(bar, barmodule.IBar)
self.root['bar'] = bar
self.assertTrue(barmodule.IBar.providedBy(bar))
+
+ bah = Bar()
+ directlyProvides(bah, barmodule.IBah)
+ self.root['bah'] = bah
+ self.assertTrue(barmodule.IBah.providedBy(bah))
+
+ blah = Bar()
+ directlyProvides(blah, barmodule.IBlah)
+ self.root['blah'] = blah
+ self.assertTrue(barmodule.IBlah.providedBy(blah))
+
transaction.commit()
self.db.close()
-
root = self.db.open().root()
barmodule = root['registry'].findModule("barmodule")
+
bar = root['bar']
self.assertTrue(barmodule.IBar.providedBy(bar))
+ bah = root['bah']
+ self.assertTrue(barmodule.IBah.providedBy(bah))
+
+ blah = root['blah']
+ self.assertTrue(barmodule.IBlah.providedBy(blah))
+
def test_persistentWeakref(self):
"""Verify interacton of declaration weak refs with ZODB
More information about the Checkins
mailing list