+
+ # not sure this is useful at all
+# def reset_queue (self):
+# self._queries = set()
+# self._queue = []
+
+ # this method adds a query to the page
+ # the query will be exposed to js when calling __expose_queries, which is done by prelude_env()
+ # additionally if run_it is set to True, this query will be asynchroneously triggered on page load
+ # in this case (exec=True) the js async callback (see manifold.asynchroneous_success)
+ # offers the option to deliver the result to a specific DOM elt (in this case, set domid)
+ # otherwise (i.e. if domid not provided), it goes through the pubsub system (so all plugins can receive it)
+ #
+ # NOTE:
+ # analyzed_query is required because it contains query_uuid that the
+ # plugins initialized in the python part will listen to. When a result is
+ # received in javascript, subresults should be publish to the appropriate
+ # query_uuid.
+ #
+ def enqueue_query (self, query, run_it=True, domid=None, analyzed_query=None):
+ # _queries is the set of all known queries
+ # XXX complex XXX self._queries = self._queries.union(set( [ query, ] ))
+ self._queries.add((query, analyzed_query))
+ # _queue is the list of queries that need to be triggered, with an optional domid
+ # we only do this if run_it is set
+ if run_it: self._queue.append ( (query.query_uuid,domid) )
+
+ def generate_records(self, query, generators, number=10):
+ self.add_js_files('js/record_generator.js');
+ js_chunk = '$(document).ready(function() { new RecordGenerator(%s,%s,%s).run(); });'%(query.to_json(),json.dumps(generators),number);
+ self.add_js_chunks(js_chunk)