[Zodb-checkins] CVS: Packages/ZConfig - SchemaInfo.py:1.1.2.7 SchemaParser.py:1.1.4.4

Fred L. Drake, Jr. fred@zope.com
Mon, 9 Dec 2002 14:12:57 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	SchemaInfo.py SchemaParser.py 
Log Message:
Use a proper marker when maxOccurs is "unbounded".

=== Packages/ZConfig/SchemaInfo.py 1.1.2.6 => 1.1.2.7 ===
--- Packages/ZConfig/SchemaInfo.py:1.1.2.6	Mon Dec  9 13:20:12 2002
+++ Packages/ZConfig/SchemaInfo.py	Mon Dec  9 14:12:55 2002
@@ -1,6 +1,31 @@
 """Objects that can describe a ZConfig schema."""
 
 
+class UnboundedThing:
+    def __lt__(self, other):
+        return False
+
+    def __le__(self, other):
+        return isinstance(other, self.__class__)
+
+    def __gt__(self, other):
+        return True
+
+    def __ge__(self, other):
+        return True
+
+    def __eq__(self, other):
+        return isinstance(other, self.__class__)
+
+    def __ne__(self, other):
+        return not isinstance(other, self.__class__)
+
+    def __repr__(self):
+        return "<Unbounded>"
+
+Unbounded = UnboundedThing()
+
+
 class KeyInfo:
     """Information about a single configuration key."""
 


=== Packages/ZConfig/SchemaParser.py 1.1.4.3 => 1.1.4.4 ===
--- Packages/ZConfig/SchemaParser.py:1.1.4.3	Mon Dec  9 12:58:12 2002
+++ Packages/ZConfig/SchemaParser.py	Mon Dec  9 14:12:55 2002
@@ -6,7 +6,7 @@
 import ZConfig
 import ZConfig.DataTypes
 
-from ZConfig.SchemaInfo import SectionInfo, KeyInfo
+from ZConfig.SchemaInfo import SectionInfo, KeyInfo, Unbounded
 
 
 default_value_type = ZConfig.DataTypes.get("str")
@@ -202,7 +202,7 @@
         maxOccurs = attrs.get("maxOccurs")
         if maxOccurs is not None:
             if maxOccurs == "unbounded":
-                maxOccurs = None
+                maxOccurs = Unbounded
             else:
                 maxOccurs = int(maxOccurs)
         else:
@@ -210,6 +210,8 @@
         minOccurs = attrs.get("minOccurs")
         if minOccurs:
             minOccurs = int(minOccurs)
+            if minOccurs > maxOccurs:
+                self.doSchemaError("minOccurs cannot be more than maxOccurs")
         else:
             minOccurs = None
         handler = attrs.get("handler")