[Zope3-checkins] CVS: Zope3/lib/python/Zope/Configuration/tests - Directives.py:1.4.6.1 testMultipleXML.py:1.2.14.1
Jim Fulton
jim@zope.com
Mon, 21 Oct 2002 05:54:19 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Configuration/tests
In directory cvs.zope.org:/tmp/cvs-serv4627/lib/python/Zope/Configuration/tests
Modified Files:
Tag: Zope3-Bangalore-TTW-Branch
Directives.py testMultipleXML.py
Log Message:
Added support for non-conflicting configuration directives. If
directives never conflict, they can supply a discriminator of None,
which will cause the normal conflict checking to be bypassed.
=== Zope3/lib/python/Zope/Configuration/tests/Directives.py 1.4 => 1.4.6.1 ===
--- Zope3/lib/python/Zope/Configuration/tests/Directives.py:1.4 Sun Sep 22 12:05:18 2002
+++ Zope3/lib/python/Zope/Configuration/tests/Directives.py Mon Oct 21 05:54:18 2002
@@ -21,6 +21,15 @@
protections=[]
+count = 0
+
+def _increment():
+ global count
+ count += 1
+
+def increment(_context):
+ return [(None, _increment, (), )]
+
class protectClass:
__implements__ = INonEmptyDirective
=== Zope3/lib/python/Zope/Configuration/tests/testMultipleXML.py 1.2 => 1.2.14.1 ===
--- Zope3/lib/python/Zope/Configuration/tests/testMultipleXML.py:1.2 Mon Jun 10 19:29:24 2002
+++ Zope3/lib/python/Zope/Configuration/tests/testMultipleXML.py Mon Oct 21 05:54:18 2002
@@ -13,6 +13,7 @@
##############################################################################
import unittest, sys, os
from tempfile import mktemp
+import Zope.Configuration.tests.Directives
from Zope.Configuration.tests.Directives import protections, done
from Zope.Configuration.xmlconfig import XMLConfig
from Zope.Testing.CleanUp import CleanUp # Base class w registry cleanup
@@ -45,11 +46,19 @@
'''<directive name="protectClass" namespace="%s"
handler="Zope.Configuration.tests.Directives.protectClass">
<subdirective name="protect" namespace="%s" />
- </directive>''' % (ns, ns),
+ </directive>
+ <directive name="increment" namespace="%s"
+ handler="Zope.Configuration.tests.Directives.increment">
+ </directive>
+ ''' % (ns, ns, ns),
+
'''
<test:protectClass
name=".Contact" permission="splat" names="update"
/>
+ <test:increment />
+ <test:increment />
+ <test:increment />
<include file="%s"/>
''' % f2), 'f1')
@@ -59,6 +68,8 @@
(".Contact", "splat", 'update'),
(".Contact", "splat", 'update2'),
])
+
+ self.assertEquals(Zope.Configuration.tests.Directives.count, 3)
def testConflicting(self):
f2=tfile(template % ('',
@@ -89,6 +100,30 @@
<include file="%s"/>
<include file="%s"/>
''' % (f2, f3)), 'f1')
+
+ x=XMLConfig(str(f1))
+
+ from Zope.Configuration.xmlconfig import ZopeConfigurationConflictError
+
+ self.assertRaises(ZopeConfigurationConflictError, x)
+
+ self.assertEquals(protections, [])
+
+
+ def testConflicting_in_same_location(self):
+ f1=tfile(template % (
+ '''<directive name="protectClass" namespace="%s"
+ handler="Zope.Configuration.tests.Directives.protectClass">
+ <subdirective name="protect" namespace="%s" />
+ </directive>''' % (ns, ns),
+ '''
+ <test:protectClass
+ name=".Contact" permission="splat" names="update"
+ />
+ <test:protectClass
+ name=".Contact" permission="splat" names="update"
+ />
+ '''), 'f1')
x=XMLConfig(str(f1))