[Zope3-checkins] CVS: Packages/ZConfig - matcher.py:1.1.2.31 schema.py:1.1.2.35

Fred L. Drake, Jr. fred@zope.com
Fri, 3 Jan 2003 00:51:14 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	matcher.py schema.py 
Log Message:
Add the methods getSectionName() and getSectionType() to SectionValue.
Disallow attribute names starting with "getSection" in the schema so there
is some reserved namespace for future expansion of the set of method for
accessing section metadata.


=== Packages/ZConfig/matcher.py 1.1.2.30 => 1.1.2.31 ===
--- Packages/ZConfig/matcher.py:1.1.2.30	Wed Jan  1 22:08:11 2003
+++ Packages/ZConfig/matcher.py	Fri Jan  3 00:50:40 2003
@@ -158,7 +158,7 @@
                     v = []
                     for s in values[i]:
                         if s is not None:
-                            v.append(s.__type__.datatype(s))
+                            v.append(s._type.datatype(s))
                         else:
                             v.append(None)
                 elif ci.name == '+':
@@ -169,7 +169,7 @@
                     v = [ci.datatype(s) for s in values[i]]
             elif ci.issection():
                 if values[i] is not None:
-                    v = values[i].__type__.datatype(values[i])
+                    v = values[i]._type.datatype(values[i])
                 else:
                     v = None
             elif name == '+':
@@ -227,18 +227,18 @@
         d = self.__dict__
         d['_attrnames'] = attrnames
         d['_values'] = values
-        d['__name__'] = name
-        d['__type__'] = type
+        d['_name'] = name
+        d['_type'] = type
 
     def __repr__(self):
-        if self.__name__:
+        if self._name:
             # probably unique for a given config file; more readable than id()
-            name = `self.__name__`
+            name = `self._name`
         else:
             # identify uniquely
             name = "at %#x" % id(self)
         clsname = self.__class__.__name__
-        return "<%s for %s %s>" % (clsname, self.__type__.name, name)
+        return "<%s for %s %s>" % (clsname, self._type.name, name)
 
     def __len__(self):
         return len(self._values)
@@ -275,3 +275,9 @@
             v = self._values[i]
             l.append('%-40s: %s' % (k, v))
         return '\n'.join(l)
+
+    def getSectionName(self):
+        return self._name
+
+    def getSectionType(self):
+        return self._type.name


=== Packages/ZConfig/schema.py 1.1.2.34 => 1.1.2.35 ===
--- Packages/ZConfig/schema.py:1.1.2.34	Thu Jan  2 18:06:58 2003
+++ Packages/ZConfig/schema.py	Fri Jan  3 00:50:40 2003
@@ -324,6 +324,9 @@
         aname = attrs.get("attribute")
         if aname:
             aname = self.identifier(aname)
+            if aname.startswith("getSection"):
+                # reserved; used for SectionValue methods to get meta-info
+                self.error("attribute names may not start with 'getSection'")
         if name in ("*", "+"):
             if not aname:
                 self.error(