[Zodb-checkins] CVS: Packages/ZConfig - matcher.py:1.6 schema.py:1.14
Fred L. Drake, Jr.
fred@zope.com
Wed, 15 Jan 2003 10:25:49 -0500
Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv19787
Modified Files:
matcher.py schema.py
Log Message:
When loading a configuration, apply the keytype conversion specified by the
container. Added corresponding test.
=== Packages/ZConfig/matcher.py 1.5 => 1.6 ===
--- Packages/ZConfig/matcher.py:1.5 Tue Jan 14 15:10:57 2003
+++ Packages/ZConfig/matcher.py Wed Jan 15 10:25:14 2003
@@ -57,11 +57,15 @@
"too many instances of %s section" % `ci.sectiontype.name`)
def addValue(self, key, value, position):
+ try:
+ realkey = self.type.keytype(key)
+ except ValueError, e:
+ raise ZConfig.DataConversionError(e, key, position)
length = len(self.type)
arbkey_info = None
for i in range(length):
k, ci = self.type[i]
- if k == key:
+ if k == realkey:
break
if ci.name == "+" and not ci.issection():
arbkey_info = i, k, ci
@@ -97,15 +101,15 @@
value = ValueInfo(value, position)
if k == '+':
if ismulti:
- if v.has_key(key):
- v[key].append(value)
+ if v.has_key(realkey):
+ v[realkey].append(value)
else:
- v[key] = [value]
+ v[realkey] = [value]
else:
- if v.has_key(key):
+ if v.has_key(realkey):
raise ZConfig.ConfigurationError(
"too many values for " + `key`)
- v[key] = value
+ v[realkey] = value
elif ismulti:
v.append(value)
else:
=== Packages/ZConfig/schema.py 1.13 => 1.14 ===
--- Packages/ZConfig/schema.py:1.13 Fri Jan 10 15:37:49 2003
+++ Packages/ZConfig/schema.py Wed Jan 15 10:25:14 2003
@@ -218,11 +218,14 @@
return name, None, aname
else:
# run the keytype converter to make sure this is a valid key
- name = self._stack[-1].keytype(name)
+ try:
+ name = self._stack[-1].keytype(name)
+ except ValueError, e:
+ self.error("could not convert key name to keytype: " + str(e))
if not aname:
aname = self.basic_key(name)
aname = self.identifier(aname.replace('-', '_'))
- return None, self.basic_key(name), aname
+ return None, name, aname
# schema loading logic