[Checkins] SVN: Zope3/trunk/src/zope/app/module/ ModuleManagers
behave differently when interfaces are involved
Ross Patterson
me at rpatterson.net
Mon Feb 5 18:11:16 EST 2007
Log message for revision 72384:
ModuleManagers behave differently when interfaces are involved
I've added a doc file and corresponding test to demonstrate.
Changed:
A Zope3/trunk/src/zope/app/module/interfaces.txt
U Zope3/trunk/src/zope/app/module/tests.py
-=-
Added: Zope3/trunk/src/zope/app/module/interfaces.txt
===================================================================
--- Zope3/trunk/src/zope/app/module/interfaces.txt 2007-02-05 23:03:44 UTC (rev 72383)
+++ Zope3/trunk/src/zope/app/module/interfaces.txt 2007-02-05 23:11:13 UTC (rev 72384)
@@ -0,0 +1,38 @@
+;-*-Doctest-*-
+=====================
+Persistent Interfaces
+=====================
+
+zope.app.module's ModuleManagers behave a little differently when
+interfaces are involved::
+
+ >>> from zope.app.module.manager import ModuleManager
+ >>> manager = ModuleManager()
+ >>> source = """\n
+ ... from zope.interface import Interface
+ ... class IFoo(Interface): pass
+ ... class IBar(IFoo): pass
+ ... """
+ >>> manager.source = source
+
+A ModuleManager doesn't get a name until it's registered and the
+zodbcode wrappers break without a name, so we can't retrieve our
+module until our manager is registered::
+
+ >>> from zope.app.testing import setup
+ >>> from zope.app.module import interfaces
+ >>> root = setup.buildSampleFolderTree()
+ >>> root_sm = setup.createSiteManager(root)
+ >>> manager = setup.addUtility(root_sm, 'foo',
+ ... interfaces.IModuleManager, manager)
+
+Now we can compile a module with interfaces and access everything
+appropriately::
+
+ >>> module = manager.getModule()
+ >>> module
+ <PersistentModule foo>
+ >>> module.IFoo
+ <PersistentInterfaceClass foo.IFoo>
+ >>> module.IBar
+ <PersistentInterfaceClass foo.IBar>
Modified: Zope3/trunk/src/zope/app/module/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/module/tests.py 2007-02-05 23:03:44 UTC (rev 72383)
+++ Zope3/trunk/src/zope/app/module/tests.py 2007-02-05 23:11:13 UTC (rev 72384)
@@ -34,7 +34,8 @@
def test_suite():
return unittest.TestSuite((
- doctest.DocFileSuite('README.txt', setUp=setUp, tearDown=tearDown),
+ doctest.DocFileSuite('README.txt', 'interfaces.txt',
+ setUp=setUp, tearDown=tearDown),
))
if __name__ == "__main__":
More information about the Checkins
mailing list