1
0
forked from ScoDoc/ScoDoc

Fix etud_info xml quote

This commit is contained in:
Emmanuel Viennet 2021-10-20 22:34:06 +02:00
parent 92de66f734
commit 280f6cf1c1
3 changed files with 17 additions and 5 deletions

View File

@ -572,17 +572,24 @@ def sendJSON(data, attached=False):
)
def sendXML(data, tagname=None, force_outer_xml_tag=True, attached=False):
def sendXML(data, tagname=None, force_outer_xml_tag=True, attached=False, quote=True):
if type(data) != list:
data = [data] # always list-of-dicts
if force_outer_xml_tag:
data = [{tagname: data}]
tagname += "_list"
doc = sco_xml.simple_dictlist2xml(data, tagname=tagname)
doc = sco_xml.simple_dictlist2xml(data, tagname=tagname, quote=quote)
return send_file(doc, filename="sco_data.xml", mime=XML_MIMETYPE, attached=attached)
def sendResult(data, name=None, format=None, force_outer_xml_tag=True, attached=False):
def sendResult(
data,
name=None,
format=None,
force_outer_xml_tag=True,
attached=False,
quote_xml=True,
):
if (format is None) or (format == "html"):
return data
elif format == "xml": # name is outer tagname
@ -591,6 +598,7 @@ def sendResult(data, name=None, format=None, force_outer_xml_tag=True, attached=
tagname=name,
force_outer_xml_tag=force_outer_xml_tag,
attached=attached,
quote=quote_xml,
)
elif format == "json":
return sendJSON(data, attached=attached)

View File

@ -363,6 +363,8 @@ def search_etud_by_name():
@scodoc7func
def etud_info(etudid=None, format="xml"):
"Donne les informations sur un etudiant"
if not format in ("xml", "json"):
raise ScoValueError("format demandé non supporté par cette fonction.")
t0 = time.time()
args = sco_etud.make_etud_args(etudid=etudid)
cnx = ndb.GetDBConnexion()
@ -449,7 +451,9 @@ def etud_info(etudid=None, format="xml"):
)
log("etud_info (%gs)" % (time.time() - t0))
return scu.sendResult(d, name="etudiant", format=format, force_outer_xml_tag=False)
return scu.sendResult(
d, name="etudiant", format=format, force_outer_xml_tag=False, quote_xml=False
)
# -------------------------- FICHE ETUDIANT --------------------------