changeset 2938:48985ef7682f

tools (xml_tools): split new lines for multi-lines text in XMLUIResult2DataFormResult to be correctly handled in data form
author Goffi <goffi@goffi.org>
date Fri, 03 May 2019 20:48:19 +0200
parents db0890c9c7db
children 18a98a541f7a
files sat/tools/xml_tools.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sat/tools/xml_tools.py	Fri May 03 20:46:59 2019 +0200
+++ b/sat/tools/xml_tools.py	Fri May 03 20:48:19 2019 +0200
@@ -335,11 +335,15 @@
     @param xmlui_data (dict): data returned by frontends for XMLUI form
     @return: dict of data usable by Wokkel's data form
     """
-    return {
-        key[len(SAT_FORM_PREFIX) :]: _cleanValue(value)
-        for key, value in xmlui_data.iteritems()
-        if key.startswith(SAT_FORM_PREFIX)
-    }
+    ret = {}
+    for key, value in xmlui_data.iteritems():
+        if not key.startswith(SAT_FORM_PREFIX):
+            continue
+        if isinstance(value, basestring) and u'\n' in value:
+            # data form expects multi-lines text to be in separated values
+            value = value.split(u'\n')
+        ret[key[len(SAT_FORM_PREFIX) :]] = _cleanValue(value)
+    return ret
 
 
 def formEscape(name):