forked from ScoDoc/DocScoDoc
Fix etud_info xml quote
This commit is contained in:
parent
92de66f734
commit
280f6cf1c1
@ -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:
|
if type(data) != list:
|
||||||
data = [data] # always list-of-dicts
|
data = [data] # always list-of-dicts
|
||||||
if force_outer_xml_tag:
|
if force_outer_xml_tag:
|
||||||
data = [{tagname: data}]
|
data = [{tagname: data}]
|
||||||
tagname += "_list"
|
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)
|
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"):
|
if (format is None) or (format == "html"):
|
||||||
return data
|
return data
|
||||||
elif format == "xml": # name is outer tagname
|
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,
|
tagname=name,
|
||||||
force_outer_xml_tag=force_outer_xml_tag,
|
force_outer_xml_tag=force_outer_xml_tag,
|
||||||
attached=attached,
|
attached=attached,
|
||||||
|
quote=quote_xml,
|
||||||
)
|
)
|
||||||
elif format == "json":
|
elif format == "json":
|
||||||
return sendJSON(data, attached=attached)
|
return sendJSON(data, attached=attached)
|
||||||
|
@ -134,4 +134,4 @@ def xml_to_dicts(element):
|
|||||||
for child in element.childNodes:
|
for child in element.childNodes:
|
||||||
if child.nodeType == ELEMENT_NODE:
|
if child.nodeType == ELEMENT_NODE:
|
||||||
childs.append(xml_to_dicts(child))
|
childs.append(xml_to_dicts(child))
|
||||||
return (element.nodeName, d, childs)
|
return (element.nodeName, d, childs)
|
||||||
|
@ -363,6 +363,8 @@ def search_etud_by_name():
|
|||||||
@scodoc7func
|
@scodoc7func
|
||||||
def etud_info(etudid=None, format="xml"):
|
def etud_info(etudid=None, format="xml"):
|
||||||
"Donne les informations sur un etudiant"
|
"Donne les informations sur un etudiant"
|
||||||
|
if not format in ("xml", "json"):
|
||||||
|
raise ScoValueError("format demandé non supporté par cette fonction.")
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
args = sco_etud.make_etud_args(etudid=etudid)
|
args = sco_etud.make_etud_args(etudid=etudid)
|
||||||
cnx = ndb.GetDBConnexion()
|
cnx = ndb.GetDBConnexion()
|
||||||
@ -449,7 +451,9 @@ def etud_info(etudid=None, format="xml"):
|
|||||||
)
|
)
|
||||||
|
|
||||||
log("etud_info (%gs)" % (time.time() - t0))
|
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 --------------------------
|
# -------------------------- FICHE ETUDIANT --------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user