[Zope3-checkins] CVS: Packages/ZConfig - schema.py:1.1.2.26
Fred L. Drake, Jr.
fred@zope.com
Wed, 18 Dec 2002 17:22:17 -0500
Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv16428
Modified Files:
Tag: zconfig-schema-devel-branch
schema.py
Log Message:
Some internal refactoring for better consistency.
=== Packages/ZConfig/schema.py 1.1.2.25 => 1.1.2.26 ===
--- Packages/ZConfig/schema.py:1.1.2.25 Wed Dec 18 16:25:32 2002
+++ Packages/ZConfig/schema.py Wed Dec 18 17:22:16 2002
@@ -204,7 +204,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)
+ any, name, attribute = self.get_name_info(attrs, "section")
if any or not name:
self.error("section name may not be '*' or '+'")
section = info.SectionInfo(name, sectiontype,
@@ -218,7 +218,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)
+ 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)
@@ -247,18 +247,11 @@
self._stack.pop().finish()
def get_key_info(self, attrs, element):
- name = attrs.get("name")
+ any, name, attribute = self.get_name_info(attrs, element)
if not name:
self.error(element + " name may not be omitted or empty")
- # run the keytype converter to make sure this is a valid key
- name = self._stack[-1].keytype(name)
datatype = self.get_datatype(attrs, "datatype", "str")
handler = self.get_handler(attrs)
- attribute = attrs.get("attribute")
- if attribute is not None:
- attribute = self._identifier(attribute)
- else:
- attribute = self._identifier(name.replace("-", "_"))
return name, datatype, handler, attribute
def start_key(self, attrs):
@@ -289,10 +282,10 @@
def end_multikey(self):
self._stack.pop().finish()
- def get_name_info(self, attrs):
+ def get_name_info(self, attrs, element):
name = attrs.get("name")
if not name:
- self.error("section name must be specified and non-empty")
+ self.error(element + " name must be specified and non-empty")
aname = attrs.get("attribute")
if aname:
aname = self._identifier(aname)
@@ -303,6 +296,8 @@
" when using '*' or '+' for a section name")
return name, None, aname
else:
+ # run the keytype converter to make sure this is a valid key
+ name = self._stack[-1].keytype(name)
if not aname:
aname = self._basic_key(name)
aname = self._identifier(aname.replace('-', '_'))