Projet

Général

Profil

0009-create_formdata-fix-XML-export-import-of-mappings-wi.patch

Benjamin Dauvergne, 23 janvier 2020 15:42

Télécharger (1,86 ko)

Voir les différences:

Subject: [PATCH 09/11] create_formdata: fix XML export/import of mappings with
 py3

 wcs/wf/create_formdata.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
wcs/wf/create_formdata.py
22 22
from quixote import get_request, get_session
23 23

  
24 24
from django.utils.functional import cached_property
25
from django.utils.encoding import force_text, force_str
25 26

  
26 27
from wcs.qommon import _
27 28
from wcs.qommon.form import (WidgetListAsTable, CompositeWidget,
......
427 428
        container = ET.SubElement(parent, 'mappings')
428 429
        for mapping in self.mappings or []:
429 430
            item = ET.SubElement(container, 'mapping')
430
            item.attrib['varname'] = unicode(mapping.varname, charset, 'replace')
431
            item.text = unicode(mapping.expression, charset, 'replace')
431
            item.attrib['varname'] = force_text(mapping.varname, encoding=charset)
432
            item.text = force_text(mapping.expression, encoding=charset)
432 433

  
433 434
    def mappings_init_with_xml(self, container, charset, include_id=False):
434 435
        self.mappings = []
435 436
        for child in container:
436
            varname = child.attrib.get('varname', '').encode(charset)
437
            expression = child.text.encode(charset)
437
            varname = force_str(child.attrib.get('varname', ''), encoding=charset)
438
            expression = force_str(child.text, encoding=charset)
438 439
            if varname:
439 440
                self.mappings.append(Mapping(varname=varname, expression=expression))
440 441

  
441
-