From d2aac186eb175a2059c5862675d14a4002a2cb69 Mon Sep 17 00:00:00 2001 From: IDK Date: Fri, 30 Apr 2021 11:04:02 +0200 Subject: [PATCH] do_formsemestre_inscription_listinscrits: json, xml, ... --- ZNotes.py | 29 ++++++++++++++--------------- sco_utils.py | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ZNotes.py b/ZNotes.py index f78684d9..cc35d2ba 100644 --- a/ZNotes.py +++ b/ZNotes.py @@ -191,15 +191,13 @@ class ZNotes(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Impl # Affecte aussi cache inscriptions self.get_formsemestre_inscription_cache().inval_cache( key=formsemestre_id - ) # > + ) else: self._getNotesCache().inval_cache( self, formsemestre_id=formsemestre_id, pdfonly=pdfonly - ) # > + ) # Affecte aussi cache inscriptions - self.get_formsemestre_inscription_cache().inval_cache( - key=formsemestre_id - ) # > + self.get_formsemestre_inscription_cache().inval_cache(key=formsemestre_id) security.declareProtected(ScoView, "clearcache") @@ -1807,18 +1805,19 @@ class ZNotes(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Impl security.declareProtected(ScoView, "do_formsemestre_inscription_listinscrits") - def do_formsemestre_inscription_listinscrits(self, formsemestre_id): + def do_formsemestre_inscription_listinscrits( + self, formsemestre_id, format=None, REQUEST=None + ): """Liste les inscrits (état I) à ce semestre et cache le résultat""" cache = self.get_formsemestre_inscription_cache() r = cache.get(formsemestre_id) - if r != None: - return r - # retreive list - r = self.do_formsemestre_inscription_list( - args={"formsemestre_id": formsemestre_id, "etat": "I"} - ) - cache.set(formsemestre_id, r) - return r + if r is None: + # retreive list + r = self.do_formsemestre_inscription_list( + args={"formsemestre_id": formsemestre_id, "etat": "I"} + ) + cache.set(formsemestre_id, r) + return scu.sendResult(REQUEST, r, format=format, name="inscrits") security.declareProtected(ScoImplement, "do_formsemestre_inscription_edit") @@ -1831,7 +1830,7 @@ class ZNotes(ObjectManager, PropertyManager, RoleManager, Item, Persistent, Impl ) # > modif inscription semestre (demission ?) # Cache inscriptions semestres - def get_formsemestre_inscription_cache(self): + def get_formsemestre_inscription_cache(self, format=None): u = self.GetDBConnexionString() if CACHE_formsemestre_inscription.has_key(u): return CACHE_formsemestre_inscription[u] diff --git a/sco_utils.py b/sco_utils.py index 6a30c3cb..a947f46e 100644 --- a/sco_utils.py +++ b/sco_utils.py @@ -582,7 +582,7 @@ def sendXML(REQUEST, data, tagname=None, force_outer_xml_tag=True): def sendResult(REQUEST, data, name=None, format=None, force_outer_xml_tag=True): - if format is None: + if (format is None) or (format == "html"): return data elif format == "xml": # name is outer tagname return sendXML(