xmlbuilder: Don't treat 0 as None in setter impl

This commit is contained in:
Cole Robinson 2013-07-14 16:01:38 -04:00
parent 9c5a1b60ee
commit 2d460a98e5
2 changed files with 15 additions and 10 deletions

View File

@ -43,6 +43,10 @@
<disk type="file" device="floppy">
<target dev="fda" bus="fdc"/>
<iotune>
<read_iops_sec>0</read_iops_sec>
<read_bytes_sec>0</read_bytes_sec>
<write_iops_sec>0</write_iops_sec>
<write_bytes_sec>0</write_bytes_sec>
<total_iops_sec>5</total_iops_sec>
<total_bytes_sec>6</total_bytes_sec>
</iotune>

View File

@ -487,17 +487,18 @@ class XMLProperty(property):
if node:
use_xpath = node.nodePath()
if val not in [None, False]:
if not node:
node = _build_xpath_node(root_node, use_xpath)
if val is True:
# Boolean property, creating the node is enough
pass
else:
node.setContent(util.xml_escape(str(val)))
else:
if val is None or val is False:
_remove_xpath_node(root_node, use_xpath)
continue
if not node:
node = _build_xpath_node(root_node, use_xpath)
if val is True:
# Boolean property, creating the node is enough
continue
node.setContent(util.xml_escape(str(val)))
def refresh_xml(self, xmlbuilder):
self.fset(xmlbuilder, self.fget(xmlbuilder), local=False)