class TestObject(xmlmap.XmlObject): txt_bool1 = xmlmap.SimpleBooleanField('boolean/text1', 'yes', 'no', required=False) txt_bool2 = xmlmap.SimpleBooleanField('boolean/text2', 'yes', 'no') num_bool1 = xmlmap.SimpleBooleanField('boolean/num1', 1, 0) num_bool2 = xmlmap.SimpleBooleanField('boolean/num2', 1, 0) opt_elem_bool = xmlmap.SimpleBooleanField('boolean/opt', 'yes', None) opt_attr_bool = xmlmap.SimpleBooleanField('boolean/@opt', 'yes', None) # xml not present at all should not result in errors missing_bool = xmlmap.SimpleBooleanField('boolean/missing', 'yes', None) missing_bool2 = xmlmap.SimpleBooleanField('boolean/missing', 'yes', 'no')
class TestObject(xmlmap.XmlObject): txt_bool1 = xmlmap.SimpleBooleanField('boolean/text1', 'yes', 'no', required=False) txt_bool2 = xmlmap.SimpleBooleanField('boolean/text2', 'yes', 'no') num_bool1 = xmlmap.SimpleBooleanField('boolean/num1', 1, 0) num_bool2 = xmlmap.SimpleBooleanField('boolean/num2', 1, 0) opt_elem_bool = xmlmap.SimpleBooleanField('boolean/opt', 'yes', None) opt_attr_bool = xmlmap.SimpleBooleanField('boolean/@opt', 'yes', None)
class XmlObj(xmlmap.XmlObject): ROOT_NAME = 'foo' id = xmlmap.StringField('@id') strings = xmlmap.StringListField('str') int = xmlmap.IntegerField('int') bool = xmlmap.SimpleBooleanField('bool', 'yes', 'no')