xmllib default value question
Jp Calderone
exarkun at flashmail.com
Thu Mar 23 12:32:00 EST 2000
I'm using the xmllib toread in configuration files, but I don't
quite understand how default values are supposed to be accessed.
I've created the tag_<attribute> dictionaries, and I'm pretty
sure the XML is correct, but I keep getting KeyErrors when I
try to look up the name of the value in the attribute dictionary.
Here's the basic code (and xml):
class ConfigParser(xmllib.XMLParser):
tag_network = {'default': 'no'}
tag_access = {'order': 'allow deny'}
tag_allow = {'host': '*', 'port': '*'}
tag_deny = {'host': '*', 'port': '*'}
def start_allow(self, attr):
self.value = (attr['host'], attr['port'])
<!DOCTYPE interface [
...
<!ELEMENT allow #EMPTY>
<!ATTLIST allow
host CDATA "*"
port CDATA "*"
>
...
]>
<interface>
<allow host="somehost.com"/>
</interface>
As far as I can tell, this should invoke the start_allow()
method with a dictionary something like
{'host': 'somehost.com', 'port': '*'} but the single line in
start_allow raises a KeyError on port. Anyone know why/how
to fix this?
Thanks in advance, jp
--
Where a calculator on the ENIAC is equipped with 18,000 vacuum tubes and
weighs 30 tons, computers in the future may have only 1,000 vacuum tubes
and
weigh only 1.5 tons. -- Popular Mechanics, March 1949
--
5:26pm up 16 days, 23:55, 3 users, load average: 0.14, 0.06, 0.01
More information about the Python-list
mailing list