[Zope3-checkins] CVS: Zope3/lib/python/Zope/Configuration - xmlconfig.py:1.8.6.1

Jim Fulton jim@zope.com
Mon, 21 Oct 2002 05:54:48 -0400


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

Modified Files:
      Tag: Zope3-Bangalore-TTW-Branch
	xmlconfig.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/xmlconfig.py 1.8 => 1.8.6.1 ===
--- Zope3/lib/python/Zope/Configuration/xmlconfig.py:1.8	Thu Sep  5 16:25:09 2002
+++ Zope3/lib/python/Zope/Configuration/xmlconfig.py	Mon Oct 21 05:54:18 2002
@@ -318,8 +318,16 @@
 
         # organize actions by discriminators
         unique = {}
+        cactions = []
         for i in range(len(actions)):
             context, loc, des, callable, args, kw = actions[i]
+            if des is None:
+                # The descriminator is None, so this directive can
+                # never conflict. We can add it directly to the
+                # configuration actions.
+                cactions.append((i, loc, (callable, args, kw)))
+                continue
+
             a = unique.setdefault(des, [])
             a.append((context._stackcopy(), i, loc, (callable, args, kw)))
 
@@ -328,7 +336,8 @@
         for des, actions in unique.items():
             path, i, loc, f = actions[0]
             for opath, i, oloc, f in actions[1:]:
-                if opath[:len(path)] != path:
+                # Test whether path is a prefix of opath
+                if opath[:len(path)] != path or (opath == path):
                     if des not in conflicts:
                         conflicts[des] = [loc]
                     conflicts[des].append(oloc)
@@ -337,7 +346,6 @@
             raise ZopeConfigurationConflictError(conflicts)
 
         # Now order the configuration directives
-        cactions = []
         for des, actions in unique.items():
             path, i, loc, f = actions.pop(0)
             cactions.append((i, loc, f))