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

Fred L. Drake, Jr. fred@zope.com
Wed, 11 Dec 2002 17:26:04 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	matcher.py 
Log Message:
Don't raise TypeError when a multi-valued field has no values and no
default values; it is still be legit if minOccurs == 0.  Also ensures
that the error message is useful if there are not enough values.


=== Packages/ZConfig/matcher.py 1.1.2.8 => 1.1.2.9 ===
--- Packages/ZConfig/matcher.py:1.1.2.8	Wed Dec 11 16:25:19 2002
+++ Packages/ZConfig/matcher.py	Wed Dec 11 17:26:03 2002
@@ -101,10 +101,13 @@
                         "no values for %s; %s required" % (s, ci.minOccurs))
                 else:
                     v = values[i] = default[:]
-            if ci.ismulti() and len(v) < ci.minOccurs:
-                raise ZConfig.ConfigurationError(
-                    "not enough values for %s; %d found, %d required"
-                    % (`key`, len(L), ci.minOccurs))
+            if ci.ismulti():
+                if v is None:
+                    v = values[i] = []
+                if len(v) < ci.minOccurs:
+                    raise ZConfig.ConfigurationError(
+                        "not enough values for %s; %d found, %d required"
+                        % (`key`, len(L), ci.minOccurs))
             if v is None:
                 if ci.ismulti():
                     v = ci.getdefault()[:]