[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/ Merge
r26212: Remove redundant layer and skin directives from the zope
Philipp von Weitershausen
philikon at philikon.de
Thu Jul 8 14:57:10 EDT 2004
Log message for revision 26213:
Merge r26212: Remove redundant layer and skin directives from the zope
namespace and move defaultSkin to the browser namespace.
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/browser.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/browser.zcml 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/browser.zcml 2004-07-08 18:57:10 UTC (rev 26213)
@@ -3,6 +3,7 @@
xmlns:browser="http://namespaces.zope.org/browser">
<browser:defaultView name="index.html" />
+ <browser:defaultSkin name="Rotterdam" />
<include package="zope.app.exception.browser" />
<include package="zope.app.traversing.browser" />
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/component/meta.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/component/meta.zcml 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/component/meta.zcml 2004-07-08 18:57:10 UTC (rev 26213)
@@ -54,24 +54,6 @@
/>
<meta:directive
- name="skin"
- schema=".metadirectives.ISkinDirective"
- handler="zope.app.component.metaconfigure.skin"
- />
-
- <meta:directive
- name="defaultSkin"
- schema=".metadirectives.IDefaultSkinDirective"
- handler="zope.app.component.metaconfigure.defaultSkin"
- />
-
- <meta:directive
- name="layer"
- schema=".metadirectives.ILayerDirective"
- handler="zope.app.component.metaconfigure.layer"
- />
-
- <meta:directive
name="serviceType"
schema=".metadirectives.IServiceTypeDirective"
handler="zope.app.component.metaconfigure.serviceType"
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/component/metaconfigure.py 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/component/metaconfigure.py 2004-07-08 18:57:10 UTC (rev 26213)
@@ -414,28 +414,3 @@
callable = provideService,
args = (serviceType, component, permission),
)
-
-def layer(_context, name):
-
- _context.action(
- discriminator = ('layer', name),
- callable = handler,
- args = (Presentation, 'defineLayer', name, _context.info)
- )
-
-def skin(_context, name, layers):
- if ',' in layers:
- raise TypeError("Commas are not allowed in layer names.")
-
- _context.action(
- discriminator = ('skin', name),
- callable = handler,
- args = (Presentation, 'defineSkin', name, layers, _context.info)
- )
-
-def defaultSkin(_context, name):
- _context.action(
- discriminator = 'defaultSkin',
- callable = handler,
- args = (Presentation, 'setDefaultSkin', name, _context.info)
- )
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/component/metadirectives.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/component/metadirectives.py 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/component/metadirectives.py 2004-07-08 18:57:10 UTC (rev 26213)
@@ -309,45 +309,7 @@
value_type=PythonIdentifier()
)
-class ILayerDirective(Interface):
- """
- Register a layer
- """
- name = TextLine(
- title=u"Layer name",
- description=u"Layer name",
- required=True
- )
-
-class ISkinDirective(Interface):
- """
- Register a skin
- """
-
- name = TextLine(
- title=u"Skin name",
- description=u"Skin name",
- required=True
- )
-
- layers = Tokens(
- title=u"The layers it consists of.",
- required=True,
- value_type=TextLine()
- )
-
-class IDefaultSkinDirective(Interface):
- """
- Register a skin
- """
-
- name = TextLine(
- title=u"Default skin name",
- description=u"Default skin name",
- required=True
- )
-
class IServiceTypeDirective(Interface):
id = TextLine(
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/component/tests/test_directives.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/component/tests/test_directives.py 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/component/tests/test_directives.py 2004-07-08 18:57:10 UTC (rev 26213)
@@ -758,34 +758,6 @@
self.assertEqual(zapi.queryView(ob, 'test', Request(IV), None), None)
self.assertEqual(zapi.getDefaultViewName(ob, Request(IV)), 'test')
- def testSkinView(self):
-
- ob = Ob()
- self.assertEqual(zapi.queryView(ob, 'test', Request(IV), None), None)
-
- xmlconfig(StringIO(template % (
- """
- <layer name="zmi" />
- <skin name="zmi" layers="zmi default" />
- <view name="test"
- factory="zope.app.component.tests.views.VZMI"
- layer="zmi"
- for="zope.app.component.tests.views.IC"
- type="zope.app.component.tests.views.IV"/>
- <view name="test"
- factory="zope.app.component.tests.views.V1"
- for="zope.app.component.tests.views.IC"
- type="zope.app.component.tests.views.IV"/>
- """
- )))
-
- self.assertEqual(
- zapi.queryView(ob, 'test', Request(IV), None).__class__,
- V1)
- self.assertEqual(
- zapi.queryView(ob, 'test', Request(IV, 'zmi'), None).__class__,
- VZMI)
-
def testResource(self):
ob = Ob()
@@ -879,34 +851,6 @@
))
self.assertRaises(ValueError, xmlconfig, config, testing=1)
-
- def testSkinResource(self):
-
- ob = Ob()
- self.assertEqual(
- zapi.queryResource('test', Request(IV), None), None)
-
- xmlconfig(StringIO(template % (
- '''
- <layer name="zmi" />
- <skin name="zmi" layers="zmi default" />
- <resource name="test"
- factory="zope.app.component.tests.views.RZMI"
- layer="zmi"
- type="zope.app.component.tests.views.IV"/>
- <resource name="test"
- factory="zope.app.component.tests.views.R1"
- type="zope.app.component.tests.views.IV"/>
- '''
- )))
-
- self.assertEqual(
- zapi.queryResource('test', Request(IV), None).__class__,
- R1)
- self.assertEqual(
- zapi.queryResource('test', Request(IV, 'zmi'), None).__class__,
- RZMI)
-
def testFactory(self):
self.assertRaises(ComponentLookupError, zapi.createObject, None, 'foo')
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/configure.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/configure.zcml 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/configure.zcml 2004-07-08 18:57:10 UTC (rev 26213)
@@ -67,9 +67,7 @@
<include package="zope.app.basicskin" />
<include package="zope.app.rotterdam" />
- <defaultSkin name="Rotterdam" />
-
<!-- Additional packages -->
<include package="zope.app.applicationcontrol" />
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/meta.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/meta.zcml 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/meta.zcml 2004-07-08 18:57:10 UTC (rev 26213)
@@ -141,6 +141,12 @@
/>
<meta:directive
+ name="defaultSkin"
+ schema=".metadirectives.IDefaultSkinDirective"
+ handler=".metaconfigure.defaultSkin"
+ />
+
+ <meta:directive
name="icon"
schema=".metadirectives.IIconDirective"
handler=".icon.IconDirective"
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/metaconfigure.py 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/metaconfigure.py 2004-07-08 18:57:10 UTC (rev 26213)
@@ -18,12 +18,12 @@
from zope.app import zapi
from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.app.component.metaconfigure import skin, layer
from zope.app.component.metaconfigure import handler
from zope.app.container.interfaces import IAdding
from zope.app.publisher.browser.globalbrowsermenuservice \
import menuItemDirective
from zope.app.component.contentdirective import ContentDirective
+from zope.app.servicenames import Presentation
# referred to through ZCML
from zope.app.publisher.browser.resourcemeta import resource, \
@@ -32,6 +32,30 @@
from zope.app.publisher.browser.viewmeta import view
from zope.app.component.interface import provideInterface
+def layer(_context, name):
+ _context.action(
+ discriminator = ('layer', name),
+ callable = handler,
+ args = (Presentation, 'defineLayer', name, _context.info)
+ )
+
+def skin(_context, name, layers):
+ if ',' in ''.join(layers):
+ raise TypeError("Commas are not allowed in layer names.")
+
+ _context.action(
+ discriminator = ('skin', name),
+ callable = handler,
+ args = (Presentation, 'defineSkin', name, layers, _context.info)
+ )
+
+def defaultSkin(_context, name):
+ _context.action(
+ discriminator = 'defaultSkin',
+ callable = handler,
+ args = (Presentation, 'setDefaultSkin', name, _context.info)
+ )
+
def defaultView(_context, name, for_=None):
type = IBrowserRequest
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/metadirectives.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/metadirectives.py 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/metadirectives.py 2004-07-08 18:57:10 UTC (rev 26213)
@@ -481,7 +481,7 @@
name = TextLine(
title=u"Name",
- description=u"The name of the skin.",
+ description=u"The name of the layer.",
required=True
)
@@ -491,12 +491,12 @@
name = TextLine(
title=u"Name",
- description=u"The name of the skin.",
+ description=u"The name of the skin",
required=True
)
layers = Tokens(
- title=u"A list of names of layers.",
+ title=u"A list of layer names",
description=u"""
This should be in order of lookup. Usually one of the layers
has the same name as the skin, and the last skin should be
@@ -505,6 +505,17 @@
value_type=TextLine()
)
+class IDefaultSkinDirective(Interface):
+ """Sets the default browser skin
+ """
+
+ name = TextLine(
+ title=u"Default skin name",
+ description=u"Default skin name",
+ required=True
+ )
+
+
class IIconDirective(Interface):
"""
Define an icon for an interface
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directives.py 2004-07-08 18:52:08 UTC (rev 26212)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directives.py 2004-07-08 18:57:10 UTC (rev 26213)
@@ -245,10 +245,57 @@
self.assertEqual(getDefaultViewName(ob, request
), 'test')
+ def testSkinResource(self):
+ self.assertEqual(
+ zapi.queryResource('test', Request(IV), None), None)
+ xmlconfig(StringIO(template % (
+ '''
+ <browser:layer name="zmi" />
+ <browser:skin name="zmi" layers="zmi default" />
+ <browser:resource
+ name="test"
+ factory="zope.app.component.tests.views.RZMI"
+ layer="zmi" />
+ <browser:resource
+ name="test"
+ factory="zope.app.component.tests.views.R1" />
+ '''
+ )))
+
+ self.assertEqual(
+ zapi.queryResource('test', request, None).__class__, R1)
+ self.assertEqual(
+ zapi.queryResource('test', TestRequest(skin='zmi'), None).__class__,
+ RZMI)
+
+ def testDefaultSkin(self):
+ self.assertEqual(queryView(ob, 'test', request, None), None)
+ xmlconfig(StringIO(template % (
+ '''
+ <browser:layer name="zmi" />
+ <browser:skin name="zmi" layers="zmi default" />
+ <browser:defaultSkin name="zmi" />
+ <browser:page name="test"
+ class="zope.app.component.tests.views.VZMI"
+ layer="zmi"
+ for="zope.app.component.tests.views.IC"
+ permission="zope.Public"
+ attribute="index"
+ />
+ <browser:page name="test"
+ class="zope.app.component.tests.views.V1"
+ for="zope.app.component.tests.views.IC"
+ permission="zope.Public"
+ attribute="index"
+ />
+ '''
+ )))
+ v = queryView(ob, 'test', TestRequest(skin=''))
+ self.assert_(issubclass(v.__class__, VZMI))
+
def testSkinPage(self):
- self.assertEqual(queryView(ob, 'test', request,
- None), None)
+ self.assertEqual(queryView(ob, 'test', request, None), None)
xmlconfig(StringIO(template % (
"""
More information about the Zope3-Checkins
mailing list