[Zodb-checkins] CVS: Packages/ZConfig - info.py:1.1.2.22 schema.py:1.1.2.37

Fred L. Drake, Jr. fred@zope.com
Fri, 3 Jan 2003 12:05:55 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	info.py schema.py 
Log Message:
Allow a sectiontype to extend an existing group.
This is needed to allow schema components to themselves be extensible (for
example, to add new concrete storage types to an abstract "storage" type).


=== Packages/ZConfig/info.py 1.1.2.21 => 1.1.2.22 ===
--- Packages/ZConfig/info.py:1.1.2.21	Wed Jan  1 05:13:28 2003
+++ Packages/ZConfig/info.py	Fri Jan  3 12:05:21 2003
@@ -203,11 +203,6 @@
     def gettypenames(self):
         return self._types.keys()
 
-    def finish(self):
-        if not self._types:
-            raise ZConfig.SchemaError(
-                "sectiongroup must contain at least on sectiontype")
-
 
 class GroupType(TypeContainer):
     def __init__(self, name):


=== Packages/ZConfig/schema.py 1.1.2.36 => 1.1.2.37 ===
--- Packages/ZConfig/schema.py:1.1.2.36	Fri Jan  3 01:04:25 2003
+++ Packages/ZConfig/schema.py	Fri Jan  3 12:05:21 2003
@@ -201,7 +201,16 @@
         sectinfo = info.SectionType(name, keytype, valuetype, datatype)
         self._schema.addtype(sectinfo)
         if self._group is not None:
+            if attrs.has_key("group"):
+                self.error("sectiontype cannot specify group"
+                           " if nested in a sectiongroup")
             self._group.addtype(sectinfo)
+        elif attrs.has_key("group"):
+            groupname = self.basic_key(attrs["group"])
+            group = self._schema.gettype(groupname)
+            if not group.istypegroup():
+                self.error("type specified as group is not a sectiongroup")
+            group.addtype(sectinfo)
         self._stack.append(sectinfo)
 
     def end_sectiontype(self):
@@ -276,7 +285,7 @@
     def end_sectiongroup(self):
         del self._prefixes[-1]
         self._group = None
-        self._stack.pop().finish()
+        self._stack.pop()
 
     def get_key_info(self, attrs, element):
         any, name, attribute = self.get_name_info(attrs, element)