[Zconfig] SVN: ZConfig/trunk/ for <section> and <multisection>, if the name attribute is omitted, assume

Fred L. Drake, Jr. fdrake at gmail.com
Wed Feb 9 13:32:15 EST 2005


Log message for revision 29091:
  for <section> and <multisection>, if the name attribute is omitted, assume
  name="*", since this is what is used most often
  

Changed:
  U   ZConfig/trunk/__init__.py
  U   ZConfig/trunk/doc/zconfig.pdf
  U   ZConfig/trunk/doc/zconfig.tex
  U   ZConfig/trunk/schema.py
  U   ZConfig/trunk/tests/test_schema.py

-=-
Modified: ZConfig/trunk/__init__.py
===================================================================
--- ZConfig/trunk/__init__.py	2005-02-09 15:30:36 UTC (rev 29090)
+++ ZConfig/trunk/__init__.py	2005-02-09 18:32:15 UTC (rev 29091)
@@ -15,7 +15,7 @@
 
 $Id: __init__.py,v 1.18 2004/04/15 20:33:32 fdrake Exp $
 """
-version_info = (2, 2)
+version_info = (2, 3)
 __version__ = ".".join([str(n) for n in version_info])
 
 from ZConfig.loader import loadConfig, loadConfigFile

Modified: ZConfig/trunk/doc/zconfig.pdf
===================================================================
(Binary files differ)

Modified: ZConfig/trunk/doc/zconfig.tex
===================================================================
--- ZConfig/trunk/doc/zconfig.tex	2005-02-09 15:30:36 UTC (rev 29090)
+++ ZConfig/trunk/doc/zconfig.tex	2005-02-09 18:32:15 UTC (rev 29091)
@@ -20,8 +20,8 @@
 \title{ZConfig Package Reference}
 
 %\date{27 October 2003}
-\release{2.2}
-\setshortversion{2.2}
+\release{2.3--}
+\setshortversion{2.3}
 
 \author{Zope Corporation}
 \authoraddress{
@@ -692,12 +692,13 @@
 
   \begin{attributedesc}{name}{\datatype{basic-key}}
     The name of the section, as it must be given in a configuration
-    instance, \code{*}, or \code{+}.  If the value is \code{*}, any
-    name not already specified as a key may be used.  If the value is
-    \code{*} or \code{+}, the \attribute{attribute} attribute must be
-    specified.  If the value is \code{*}, any name is allowed, or the
-    name may be omitted.  If the value is \code{+}, any name is
-    allowed, but some name must be provided.
+    instance, \code{*}, or \code{+}.  If the value is \code{*} or this
+    attribute is omitted, any name not already specified as a key may
+    be used.  If the value is \code{*} or \code{+}, the
+    \attribute{attribute} attribute must be specified.  If the value
+    is \code{*}, any name is allowed, or the name may be omitted.  If
+    the value is \code{+}, any name is allowed, but some name must be
+    provided.
   \end{attributedesc}
 
   \begin{attributedesc}{required}{\code{yes|no}}
@@ -739,10 +740,11 @@
     For a \element{multisection}, any name not already specified as a
     key may be used.  If the value is \code{*} or \code{+}, the
     \attribute{attribute} attribute must be specified.  If the value
-    is \code{*}, any name is allowed, or the name may be omitted.  If
-    the value is \code{+}, any name is allowed, but some name must be
-    provided.  No other value for the \attribute{name} attribute is
-    allowed for a \element{multisection}.
+    is \code{*} or this attribute is omitted, any name is allowed, or
+    the name may be omitted.  If the value is \code{+}, any name is
+    allowed, but some name must be provided.  No other value for the
+    \attribute{name} attribute is allowed for a
+    \element{multisection}.
   \end{attributedesc}
 
   \begin{attributedesc}{required}{\code{yes|no}}

Modified: ZConfig/trunk/schema.py
===================================================================
--- ZConfig/trunk/schema.py	2005-02-09 15:30:36 UTC (rev 29090)
+++ ZConfig/trunk/schema.py	2005-02-09 18:32:15 UTC (rev 29091)
@@ -235,8 +235,8 @@
         handler = self.get_handler(attrs)
         return name or any, datatype, handler, attribute
 
-    def get_name_info(self, attrs, element):
-        name = attrs.get("name")
+    def get_name_info(self, attrs, element, default=None):
+        name = attrs.get("name", default)
         if not name:
             self.error(element + " name must be specified and non-empty")
         aname = attrs.get("attribute")
@@ -354,7 +354,7 @@
         sectiontype = self.get_sectiontype(attrs)
         handler = self.get_handler(attrs)
         min = self.get_required(attrs) and 1 or 0
-        any, name, attribute = self.get_name_info(attrs, "section")
+        any, name, attribute = self.get_name_info(attrs, "section", "*")
         if any and not attribute:
             self.error(
                 "attribute must be specified if section name is '*' or '+'")
@@ -369,7 +369,7 @@
     def start_multisection(self, attrs):
         sectiontype = self.get_sectiontype(attrs)
         min, max = self.get_ordinality(attrs)
-        any, name, attribute = self.get_name_info(attrs, "multisection")
+        any, name, attribute = self.get_name_info(attrs, "multisection", "*")
         if any not in ("*", "+"):
             self.error("multisection must specify '*' or '+' for the name")
         handler = self.get_handler(attrs)

Modified: ZConfig/trunk/tests/test_schema.py
===================================================================
--- ZConfig/trunk/tests/test_schema.py	2005-02-09 15:30:36 UTC (rev 29090)
+++ ZConfig/trunk/tests/test_schema.py	2005-02-09 18:32:15 UTC (rev 29091)
@@ -606,6 +606,19 @@
         conf = self.load_config_text(schema, "<sect/>")
         self.assertEqual(conf.attr.key, "value")
 
+    def test_simple_anonymous_section_without_name(self):
+        # make sure we get the same behavior without name='*'
+        schema = self.load_schema_text("""\
+            <schema>
+              <sectiontype name='sect'>
+                <key name='key' default='value'/>
+              </sectiontype>
+              <section type='sect' attribute='attr'/>
+            </schema>
+            """)
+        conf = self.load_config_text(schema, "<sect/>")
+        self.assertEqual(conf.attr.key, "value")
+
     def test_simple_anynamed_section(self):
         schema = self.load_schema_text("""\
             <schema>
@@ -640,6 +653,24 @@
                                      </t2>
                                      """)
 
+    def test_nested_abstract_sectiontype_without_name(self):
+        # make sure we get the same behavior without name='*'
+        schema = self.load_schema_text("""\
+            <schema>
+              <abstracttype name='abstract'/>
+              <sectiontype name='t1' implements='abstract'/>
+              <sectiontype name='t2' implements='abstract'>
+                <section type='abstract' name='s1'/>
+              </sectiontype>
+              <section type='abstract' attribute='s2'/>
+            </schema>
+            """)
+        conf = self.load_config_text(schema, """\
+                                     <t2>
+                                       <t1 s1/>
+                                     </t2>
+                                     """)
+
     def test_reserved_attribute_prefix(self):
         template = """\
             <schema>
@@ -657,9 +688,9 @@
         check("<multikey name='a' attribute='getSection'/>")
         check("<multikey name='a' attribute='getSectionThing'/>")
         check("<section type='s' name='*' attribute='getSection'/>")
-        check("<section type='s' name='*' attribute='getSectionThing'/>")
+        check("<section type='s' attribute='getSectionThing'/>")
         check("<multisection type='s' name='*' attribute='getSection'/>")
-        check("<multisection type='s' name='*' attribute='getSectionThing'/>")
+        check("<multisection type='s' attribute='getSectionThing'/>")
 
     def test_sectiontype_as_schema(self):
         schema = self.load_schema_text("""\



More information about the ZConfig mailing list