[Zodb-checkins] CVS: Packages/ZConfig - info.py:1.7 loader.py:1.7 schema.py:1.11

Fred L. Drake, Jr. fred@zope.com
Thu, 9 Jan 2003 00:43:03 -0500


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

Modified Files:
	info.py loader.py schema.py 
Log Message:
Change some naming based on a discussion with Chris and Shane; the primary
intent being to make this easier to explain.

- <sectiongroup type="foo"/> becomes <abstracttype name="foo"/>
- <sectiontype type="foo"/> becomes <sectiontype name="foo"/>
- <sectiontype ... group="foo"/> becomes <sectiontype ... implements="foo"/>
- several internal names get changed to use names consistent with the
  new terminology


=== Packages/ZConfig/info.py 1.6 => 1.7 ===
--- Packages/ZConfig/info.py:1.6	Mon Jan  6 17:30:18 2003
+++ Packages/ZConfig/info.py	Thu Jan  9 00:42:28 2003
@@ -88,7 +88,7 @@
         clsname = self.__class__.__name__
         return "<%s for %s>" % (clsname, `self.name`)
 
-    def istypegroup(self):
+    def isabstract(self):
         return False
 
     def ismulti(self):
@@ -160,7 +160,7 @@
                 raise ZConfig.SchemaError(
                     "sections which can occur more than once must"
                     " specify a target attribute name")
-        if sectiontype.istypegroup():
+        if sectiontype.isabstract():
             datatype = None
         else:
             datatype = sectiontype.datatype
@@ -197,7 +197,7 @@
             return None
 
 
-class GroupType:
+class AbstractType:
     def __init__(self, name):
         self._subtypes = {}
         self.name = name
@@ -209,7 +209,7 @@
         try:
             return self._subtypes[name]
         except KeyError:
-            raise ZConfig.SchemaError("no subtype %s in group %s"
+            raise ZConfig.SchemaError("no sectiontype %s in abstracttype %s"
                                       % (`name`, `self.name`))
 
     def getsubtypenames(self):
@@ -217,7 +217,7 @@
         L.sort()
         return L
 
-    def istypegroup(self):
+    def isabstract(self):
         return True
 
 
@@ -315,7 +315,7 @@
                         raise ZConfig.ConfigurationError(
                             "section name %s already in use for key" % key)
                     st = info.sectiontype
-                    if st.istypegroup():
+                    if st.isabstract():
                         try:
                             st = st.getsubtype(type)
                         except ZConfig.ConfigurationError:
@@ -327,17 +327,17 @@
                             "name %s must be used for a %s section"
                             % (`name`, `st.name`))
                     return index
-            # else must be a section or a sectiongroup:
+            # else must be a sectiontype or an abstracttype:
             elif info.sectiontype.name == type:
                 if not (name or info.allowUnnamed()):
                     raise ZConfig.ConfigurationError(
                         `type` + " sections must be named")
                 return index
-            elif info.sectiontype.istypegroup():
+            elif info.sectiontype.isabstract():
                 st = info.sectiontype
                 if st.name == type:
                     raise ZConfig.ConfigurationError(
-                        "cannot define section with a sectiongroup type")
+                        "cannot define section with an abstract type")
                 try:
                     st = st.getsubtype(type)
                 except ZConfig.ConfigurationError:
@@ -350,11 +350,11 @@
     def getsectioninfo(self, type, name):
         i = self.getsectionindex(type, name)
         st = self._children[i][1]
-        if st.istypegroup():
+        if st.isabstract():
             st = st.gettype(type)
         return st
 
-    def istypegroup(self):
+    def isabstract(self):
         return False
 
 


=== Packages/ZConfig/loader.py 1.6 => 1.7 ===
--- Packages/ZConfig/loader.py:1.6	Tue Jan  7 15:02:35 2003
+++ Packages/ZConfig/loader.py	Thu Jan  9 00:42:28 2003
@@ -168,7 +168,7 @@
 
 class ConfigLoader(BaseLoader):
     def __init__(self, schema):
-        if schema.istypegroup():
+        if schema.isabstract():
             raise ZConfig.SchemaError(
                 "cannot check a configuration an abstract type")
         BaseLoader.__init__(self)
@@ -186,12 +186,12 @@
         if delegatename:
             raise NotImpementedError("section delegation is not yet supported")
         t = self.schema.gettype(type)
-        if t.istypegroup():
+        if t.isabstract():
             raise ZConfig.ConfigurationError(
                 "concrete sections cannot match abstract section types;"
                 " found abstract type " + `type`)
         ci = parent.type.getsectioninfo(type, name)
-        assert not ci.istypegroup()
+        assert not ci.isabstract()
         if not ci.isAllowedName(name):
             raise ZConfig.ConfigurationError(
                 "%s is not an allowed name for %s sections"


=== Packages/ZConfig/schema.py 1.10 => 1.11 ===
--- Packages/ZConfig/schema.py:1.10	Tue Jan  7 17:24:55 2003
+++ Packages/ZConfig/schema.py	Thu Jan  9 00:42:28 2003
@@ -47,7 +47,7 @@
 class BaseParser(xml.sax.ContentHandler):
 
     _cdata_tags = "description", "metadefault", "example", "default"
-    _handled_tags = ("import", "sectiongroup", "sectiontype",
+    _handled_tags = ("import", "abstracttype", "sectiontype",
                      "key", "multikey", "section", "multisection")
 
     def __init__(self, registry, loader, url):
@@ -60,7 +60,6 @@
         self._prefixes = []
         self._schema = None
         self._stack = []
-        self._group = None
         self._url = url
         self._components = {}
 
@@ -285,9 +284,9 @@
         pass
 
     def start_sectiontype(self, attrs):
-        name = attrs.get("type")
+        name = attrs.get("name")
         if not name:
-            self.error("sectiontype type must not be omitted or empty")
+            self.error("sectiontype name must not be omitted or empty")
         name = self.basic_key(name)
         self.push_prefix(attrs)
         keytype, valuetype, datatype = self.get_sect_typeinfo(attrs)
@@ -296,7 +295,7 @@
             base = self._schema.gettype(basename)
             if not self._localtypes.has_key(basename):
                 self.error("cannot extend type derived outside component")
-            if base.istypegroup():
+            if base.isabstract():
                 self.error("sectiontype cannot extend an abstract type")
             if attrs.has_key("keytype"):
                 self.error("derived sectiontype may not specify a keytype")
@@ -305,17 +304,13 @@
         else:
             sectinfo = self._schema.createSectionType(
                 name, keytype, valuetype, datatype)
-        if self._group is not None:
-            if attrs.has_key("group"):
-                self.error("sectiontype cannot specify group"
-                           " if nested in a sectiongroup")
-            self._group.addsubtype(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.addsubtype(sectinfo)
+        if attrs.has_key("implements"):
+            ifname = self.basic_key(attrs["implements"])
+            interface = self._schema.gettype(ifname)
+            if not interface.isabstract():
+                self.error(
+                    "type specified by implements is not an abstracttype")
+            interface.addsubtype(sectinfo)
         self._stack.append(sectinfo)
 
     def end_sectiontype(self):
@@ -353,21 +348,16 @@
     def end_multisection(self):
         self._stack.pop()
 
-    def start_sectiongroup(self, attrs):
-        if self._group is not None:
-            self.error("sectiongroup elements cannot be nested")
-        self.push_prefix(attrs)
-        name = attrs.get("type")
+    def start_abstracttype(self, attrs):
+        name = attrs.get("name")
         if not name:
-            self.error("sectiongroup must be named")
+            self.error("abstracttype name must not be omitted or empty")
         name = self.basic_key(name)
-        self._group = info.GroupType(name)
-        self._schema.addtype(self._group)
-        self._stack.append(self._group)
+        abstype = info.AbstractType(name)
+        self._schema.addtype(abstype)
+        self._stack.append(abstype)
 
-    def end_sectiongroup(self):
-        self.pop_prefix()
-        self._group = None
+    def end_abstracttype(self):
         self._stack.pop()
 
     def start_key(self, attrs):