[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/publisher/browser/
fix the way the skins and layers modules are injected into
the namespace
Fred L. Drake, Jr.
fdrake at gmail.com
Tue Mar 8 01:43:20 EST 2005
Log message for revision 29416:
fix the way the skins and layers modules are injected into the namespace
of the parent package, with tests
Changed:
U Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
-=-
Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2005-03-08 00:01:24 UTC (rev 29415)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2005-03-08 06:43:20 UTC (rev 29416)
@@ -39,11 +39,12 @@
# Create special modules that contain all layers and skins
from types import ModuleType as module
import sys
-layers = module('layers')
-sys.modules['zope.app.layers'] = layers
+import zope.app
+zope.app.layers = module('layers')
+sys.modules['zope.app.layers'] = zope.app.layers
-skins = module('skins')
-sys.modules['zope.app.skins'] = skins
+zope.app.skins = module('skins')
+sys.modules['zope.app.skins'] = zope.app.skins
def layer(_context, name=None, interface=None, base=IBrowserRequest):
@@ -155,7 +156,7 @@
# Add the layer to the layers module.
# Note: We have to do this immediately, so that directives using the
# InterfaceField can find the layer.
- setattr(layers, name, interface)
+ setattr(zope.app.layers, name, interface)
path = 'zope.app.layers.'+name
else:
path = interface.__module__ + '.' + interface.getName()
@@ -169,7 +170,7 @@
# Make the interface available in the `zope.app.layers` module, so
# that other directives can find the interface under the name
# before the CA is setup.
- setattr(layers, name, interface)
+ setattr(zope.app.layers, name, interface)
# Register the layer interface as an interface
_context.action(
@@ -263,7 +264,7 @@
# Add the layer to the skins module.
# Note: We have to do this immediately, so that directives using the
# InterfaceField can find the layer.
- setattr(skins, name, interface)
+ setattr(zope.app.skins, name, interface)
path = 'zope.app.skins'+name
# Register the layers
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2005-03-08 00:01:24 UTC (rev 29415)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2005-03-08 06:43:20 UTC (rev 29416)
@@ -115,7 +115,29 @@
XMLConfig('meta.zcml', zope.app.publisher.browser)()
ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
+ def testLayer(self):
+ self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
+ None)
+ xmlconfig(StringIO(
+ template % '<browser:layer name="testlayer" />'
+ ))
+ testlayer = zapi.getUtility(ILayer, "testlayer")
+ import zope.app.layers
+ self.assert_(zope.app.layers.testlayer is testlayer)
+ def testSkin(self):
+ self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
+ None)
+ xmlconfig(StringIO(template % (
+ '''
+ <browser:layer name="default" />
+ <browser:skin name="testskin" layers="default" />
+ '''
+ )))
+ testskin = zapi.getUtility(ISkin, "testskin")
+ import zope.app.skins
+ self.assert_(zope.app.skins.testskin is testskin)
+
def testPage(self):
self.assertEqual(zapi.queryMultiAdapter((ob, request), name='test'),
None)
More information about the Zope3-Checkins
mailing list