[Zodb-checkins] CVS: Packages/ZConfig - matcher.py:1.1.2.14

Fred L. Drake, Jr. fred@zope.com
Thu, 12 Dec 2002 14:10:46 -0500


Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv23279

Modified Files:
      Tag: zconfig-schema-devel-branch
	matcher.py 
Log Message:
Minor edge case fixes.


=== Packages/ZConfig/matcher.py 1.1.2.13 => 1.1.2.14 ===
--- Packages/ZConfig/matcher.py:1.1.2.13	Thu Dec 12 13:48:58 2002
+++ Packages/ZConfig/matcher.py	Thu Dec 12 14:10:46 2002
@@ -35,13 +35,16 @@
         i = self.type.getsectionindex(type, name)
         ci = self.type.getsectioninfo(type, name)
         v = self._values[i]
-        if v is None and ci.ismulti():
-            v = [sectvalue]
-            self._values[i] = v
+        if v is None:
+            if ci.ismulti():
+                self._values[i] = [sectvalue]
+            else:
+                self._values[i] = sectvalue
         elif ci.ismulti():
             v.append(sectvalue)
         else:
-            self._values[i] = sectvalue
+            raise ZConfig.ConfigurationError(
+                "too many instances of %s section" % `ci.sectiontype.name`)
 
     def addValue(self, key, value):
         length = len(self.type)
@@ -105,10 +108,8 @@
                     raise ZConfig.ConfigurationError(
                         "not enough values for %s; %d found, %d required"
                         % (`key`, len(L), ci.minOccurs))
-            if v is None:
-                if ci.issection():
-                    v = []
-                elif ci.ismulti():
+            if v is None and not ci.issection():
+                if ci.ismulti():
                     v = ci.getdefault()[:]
                 else:
                     v = ci.getdefault()