[Checkins] SVN: zope.browserzcml2/trunk/src/zope/browserzcml2/ test
conflicts; make sure that new-style browser2:page conflicts
Philipp von Weitershausen
philikon at philikon.de
Fri Apr 21 14:39:00 EDT 2006
Log message for revision 67249:
test conflicts; make sure that new-style browser2:page conflicts
with old-style browser:page directive when necessary
Changed:
U zope.browserzcml2/trunk/src/zope/browserzcml2/README.txt
U zope.browserzcml2/trunk/src/zope/browserzcml2/tests.py
U zope.browserzcml2/trunk/src/zope/browserzcml2/zcml.py
-=-
Modified: zope.browserzcml2/trunk/src/zope/browserzcml2/README.txt
===================================================================
--- zope.browserzcml2/trunk/src/zope/browserzcml2/README.txt 2006-04-21 18:24:24 UTC (rev 67248)
+++ zope.browserzcml2/trunk/src/zope/browserzcml2/README.txt 2006-04-21 18:39:00 UTC (rev 67249)
@@ -89,7 +89,7 @@
... """) # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
- ZopeXMLConfigurationError: File "<string>", line 6.0-11.6
+ ZopeXMLConfigurationError: File "<string>", line 7.0-12.6
ConfigurationError: The browser page factory needs to provide
IBrowserPublisher. A convenient base class is zope.formlib.Page.
@@ -226,4 +226,48 @@
Conflicts
---------
-XXX
+Pages registered for the same interface under the same name and on the
+same layer conflict. For example, take two pages that both want to be
+called ``conflict.html`` (note that they don't necessarily have to be
+registered with exactly the same directive):
+
+ >>> run_config("""
+ ... <browser2:page
+ ... for="*"
+ ... name="conflict.html"
+ ... factory="zope.browserzcml2.README.MacGyverPage"
+ ... permission="zope.Public"
+ ... />
+ ... <browser2:pageTemplate
+ ... for="*"
+ ... name="conflict.html"
+ ... template="test.pt"
+ ... permission="zope.Public"
+ ... />
+ ... """) # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ ConfigurationConflictError: Conflicting configuration actions
+ ...
+
+Pages defined via the directives from ``zope.browserzcml2`` even
+conflict with the old-style ``browser:page`` directives:
+
+ >>> run_config("""
+ ... <browser2:page
+ ... for="*"
+ ... name="conflict.html"
+ ... factory="zope.browserzcml2.README.MacGyverPage"
+ ... permission="zope.Public"
+ ... />
+ ... <browser:page
+ ... for="*"
+ ... name="conflict.html"
+ ... template="test.pt"
+ ... permission="zope.Public"
+ ... />
+ ... """) # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ ConfigurationConflictError: Conflicting configuration actions
+ ...
Modified: zope.browserzcml2/trunk/src/zope/browserzcml2/tests.py
===================================================================
--- zope.browserzcml2/trunk/src/zope/browserzcml2/tests.py 2006-04-21 18:24:24 UTC (rev 67248)
+++ zope.browserzcml2/trunk/src/zope/browserzcml2/tests.py 2006-04-21 18:39:00 UTC (rev 67249)
@@ -20,6 +20,7 @@
import zope.browserzcml2
import zope.component.testing
+import zope.app.publisher.browser
from zope.testing import doctest, module
from zope.configuration import xmlconfig
@@ -30,6 +31,7 @@
template = """\
<configure
xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
xmlns:browser2="http://namespaces.zope.org/browser2"
>
%s
@@ -40,6 +42,7 @@
def setUp(test):
global _context
_context = xmlconfig.file('meta.zcml', zope.browserzcml2)
+ xmlconfig.file('meta.zcml', zope.app.publisher.browser, _context)
test.globs['run_config'] = run_config
module.setUp(test, 'zope.browserzcml2.README')
zope.component.testing.setUp(test)
Modified: zope.browserzcml2/trunk/src/zope/browserzcml2/zcml.py
===================================================================
--- zope.browserzcml2/trunk/src/zope/browserzcml2/zcml.py 2006-04-21 18:24:24 UTC (rev 67248)
+++ zope.browserzcml2/trunk/src/zope/browserzcml2/zcml.py 2006-04-21 18:39:00 UTC (rev 67249)
@@ -24,6 +24,7 @@
import zope.i18nmessageid
_ = zope.i18nmessageid.MessageFactory('zope')
+from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.browserzcml2.interfaces import IViewCharacteristics
@@ -62,6 +63,10 @@
_handle_menu(_context, menu, title, (for_,), name, permission, layer)
+ # emit an empty action that has the same descriminator as the
+ # old-school browser:page directive handler; that way we'll get
+ # proper conflicts
+ _context.action(discriminator=('view', for_, name, IBrowserRequest, layer))
class IPageTemplateDirective(IViewCharacteristics, IRegisterInMenu):
"""Define a browser page from a page template"""
@@ -157,4 +162,3 @@
def __call__(self):
pass
-
More information about the Checkins
mailing list