[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration/tests - Directives.py:1.6 testMultipleXML.py:1.4

Jim Fulton jim@zope.com
Tue, 19 Nov 2002 18:25:46 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Configuration/tests
In directory cvs.zope.org:/tmp/cvs-serv11465/lib/python/Zope/Configuration/tests

Modified Files:
	Directives.py testMultipleXML.py 
Log Message:

Two changes that were far reaching and interdependent.

- Changed existing directives that mention interfaces to register
  those interfaces with the global interface service.

- Moved all configuration support (except that in Zope.Configuration)
  into Zope.App. This was necessary to get the order of execution such
  that the interface service was defined before directives that used
  interfaces were used.  This is a change that has been needed for
  some time.



=== Zope3/lib/python/Zope/Configuration/tests/Directives.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/Configuration/tests/Directives.py:1.5	Wed Nov  6 17:30:22 2002
+++ Zope3/lib/python/Zope/Configuration/tests/Directives.py	Tue Nov 19 18:25:15 2002
@@ -22,6 +22,15 @@
 
 protections=[]
 
+count = 0
+
+def _increment():
+    global count
+    count += 1
+
+def increment(_context):
+    return [(None, _increment, (), )]
+
 class protectClass:
 
     __class_implements__ = INonEmptyDirective


=== Zope3/lib/python/Zope/Configuration/tests/testMultipleXML.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Configuration/tests/testMultipleXML.py:1.3	Fri Nov  8 14:00:51 2002
+++ Zope3/lib/python/Zope/Configuration/tests/testMultipleXML.py	Tue Nov 19 18:25:15 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
@@ -47,11 +48,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')
 
@@ -61,6 +70,8 @@
             (".Contact", "splat", 'update'),
             (".Contact", "splat", 'update2'),
             ])
+
+        self.assertEquals(Zope.Configuration.tests.Directives.count, 3)
         
     def testConflicting(self):
         f2=tfile(template % ('',
@@ -91,6 +102,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))