From: Thierry Parmentelat Date: Mon, 4 Mar 2013 15:17:49 +0000 (+0100) Subject: fix json'ing a manyfold query X-Git-Tag: myslice-django-0.1-1~77 X-Git-Url: http://git.onelab.eu/?p=unfold.git;a=commitdiff_plain;h=ca4221595008a3344cfa69930e7b8ec8b3660453 fix json'ing a manyfold query --- diff --git a/engine/manifoldquery.py b/engine/manifoldquery.py index b8f594e9..188a1d45 100644 --- a/engine/manifoldquery.py +++ b/engine/manifoldquery.py @@ -36,10 +36,13 @@ class ManifoldQuery: # xxx unique can be removed, but for now we pad the js structure unique=0 + aq = self.analyzed_query.to_json() if self.analyzed_query else 'null' # subqueries is a dictionary method:query - sq=", ".join ( [ "'%s':%s" % (method, subquery.to_json()) + if not self.subqueries: + sq="{}" + else: + sq=", ".join ( [ "'%s':%s" % (method, subquery.to_json()) for (method, subquery) in self.subqueries.iteritems()]) + sq="{%s}"%sq - aq = self.analyzed_query.to_json() if self.analyzed_query else 'null' - - return "new Query('%(a)s', '%(m)s', '%(t)s', %(f)s, %(p)s, %(c)s, %(unique)s, '%(uuid)s', %(aq)s, {{%(sq)s}})"%locals() + return """ new Query('%(a)s', '%(m)s', '%(t)s', %(f)s, %(p)s, %(c)s, %(unique)s, '%(uuid)s', %(aq)s, %(sq)s)"""%locals()