[Zope3-checkins] CVS: Packages/ZConfig - schema.py:1.1.2.6

Fred L. Drake, Jr. fred@zope.com
Wed, 11 Dec 2002 22:12:23 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	schema.py 
Log Message:
start_section():  Support both the name of the section type and a
    datatype converter for sections.  The required sectiontype
    attribute gives the name of the section type in the config file,
    and the optional type attribute gives the name of the datatype
    object.


=== Packages/ZConfig/schema.py 1.1.2.5 => 1.1.2.6 ===
--- Packages/ZConfig/schema.py:1.1.2.5	Wed Dec 11 15:18:15 2002
+++ Packages/ZConfig/schema.py	Wed Dec 11 22:12:23 2002
@@ -135,9 +135,9 @@
 
     def start_section(self, attrs):
         self.push_prefix(attrs)
-        type = attrs.get("type")
+        type = attrs.get("sectiontype")
         if not type:
-            self.doSchemaError("section must specify type")
+            self.doSchemaError("section must specify sectiontype")
         if attrs.has_key("keytype"):
             keytype = datatypes.get(attrs["keytype"])
         else:
@@ -146,13 +146,17 @@
             nametype = datatypes.get(attrs["nametype"])
         else:
             nametype = default_name_type
+        datatype = attrs.get("type")
+        if datatype:
+            datatype = datatypes.get(self.get_classname(datatype))
         maxOccurs, minOccurs, handler = self.get_common_info(attrs)
         any, names, attribute = self.get_names_info(attrs, nametype)
         if self._stack:
             parent = self._stack[-1]
         else:
             parent = self._schema
-        section = info.SectionInfo(type, None, minOccurs, maxOccurs, handler,
+        section = info.SectionInfo(type, datatype, minOccurs, maxOccurs,
+                                   handler,
                                    attribute, keytype, names, nametype)
         if any:
             parent.addsection(None, section)