Projet

Général

Profil

0002-fields-handle-non-string-value-in-export_to_xml-8402.patch

Benjamin Dauvergne, 06 novembre 2015 13:09

Télécharger (1,42 ko)

Voir les différences:

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(-)
wcs/fields.py
177 177
                el = ET.SubElement(field, attribute)
178 178
                if type(val) is dict:
179 179
                    for k, v in val.items():
180
                        ET.SubElement(el, k).text = unicode(v, charset, 'replace')
180
                        if isinstance(v, str):
181
                            text_value = unicode(v, charset, 'replace')
182
                        else:
183
                            # field having non str value in dictionnary field must overload
184
                            # import_to_xml to handle import
185
                            text_value = unicode(v)
186
                        ET.SubElement(el, k).text = text_value
181 187
                elif type(val) is list:
182 188
                    if attribute[-1] == 's':
183 189
                        atname = attribute[:-1]
184
-