Projet

Général

Profil

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

Benjamin Dauvergne, 04 octobre 2015 14:19

Télécharger (1,5 ko)

Voir les différences:

Subject: [PATCH 2/3] fields: in export_to_xml() handle non string value for
 dictionnary fields (#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 | 10 +++++++++-
 1 file changed, 9 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
184
                            # in dictionnary field must
185
                            # overloaf import_to_xml to
186
                            # handle import
187
                            text_value = unicode(v)
188
                        ET.SubElement(el, k).text = text_value
181 189
                elif type(val) is list:
182 190
                    if attribute[-1] == 's':
183 191
                        atname = attribute[:-1]
184
-