X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=engine%2Fmanifoldquery.py;h=ce9f3ea4847ee8cdd6d1e41bcd643e1485409c54;hb=171b1ca63f0b8ad399fbb063a018513b8e4ea03b;hp=b8f594e920d021c915745a4e8a7d58a2bf658bed;hpb=a222cef0a10a5517349f05cea0e382b35e3a14a6;p=unfold.git diff --git a/engine/manifoldquery.py b/engine/manifoldquery.py index b8f594e9..ce9f3ea4 100644 --- a/engine/manifoldquery.py +++ b/engine/manifoldquery.py @@ -36,10 +36,31 @@ 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() + + # 4amine + # xxx + # this should build an object from a dict as received from javascript + # to see an example just look at the server's output + # incoming POST + def fill_from_dict (self, d): + print d + for key in d.keys(): + for arg in ['action', 'method', 'filters', 'fields', 'timestamp', 'params']: + if arg in key: + # dirty hack around fields; fields must be a list + if arg == 'fields': + setattr(self, arg, [d[key]]) + else: + setattr(self, arg, d[key]) + break - return "new Query('%(a)s', '%(m)s', '%(t)s', %(f)s, %(p)s, %(c)s, %(unique)s, '%(uuid)s', %(aq)s, {{%(sq)s}})"%locals()