From 2c2cbcb6c2b60b6efbef153ea20dad2969f8cfef Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Sun, 4 Oct 2015 14:06:00 +0200 Subject: [PATCH 2/4] fields: handle non string value in export_to_xml() (#8402) Fields using this facility must override import_from_xml() to convert the imported string value to the real type, for example a list of strings converted to CSV, must be splitted. --- wcs/fields.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wcs/fields.py b/wcs/fields.py index c23ebef..4781fd5 100644 --- a/wcs/fields.py +++ b/wcs/fields.py @@ -177,7 +177,13 @@ class Field(object): el = ET.SubElement(field, attribute) if type(val) is dict: for k, v in val.items(): - ET.SubElement(el, k).text = unicode(v, charset, 'replace') + if isinstance(v, str): + text_value = unicode(v, charset, 'replace') + else: + # field having non str value in dictionnary field must overloaf + # import_to_xml to handle import + text_value = unicode(v) + ET.SubElement(el, k).text = text_value elif type(val) is list: if attribute[-1] == 's': atname = attribute[:-1] -- 2.1.4