X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=unfold%2Fpage.py;h=834be7e32af5e609622b377e2d0a53767cbaecb2;hb=08a5dcb65c29f21f1b08cc43a6fd5a946004ae53;hp=07ce237a3aa02467bd3d0503cf111db2853439b5;hpb=d9bbe0a36624c6fe558c05307964be1b3ed4e3b1;p=myslice.git diff --git a/unfold/page.py b/unfold/page.py index 07ce237a..834be7e3 100644 --- a/unfold/page.py +++ b/unfold/page.py @@ -49,7 +49,7 @@ class Page: # self._queue = [] # this method adds a query to the page - # the query will be exposed to js when calling expose_queries + # 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) @@ -69,14 +69,15 @@ class Page: # 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): + def generate_records(self, query, generators, number=10): self.add_js_files('js/record_generator.js'); - self.add_js_chunks('$(document).ready(function() { new RecordGenerator(' + query.to_json() + ', ' + json.dumps(generators) + ', 10).run(); });') - + js_chunk = '$(document).ready(function() { new RecordGenerator(%s,%s,%s).run(); });'%(query.to_json(),json.dumps(generators),number); + self.add_js_chunks(js_chunk) + # return the javascript code for exposing queries # all queries are inserted in the global manifold object # in addition, the ones enqueued with 'run_it=True' are triggered - def expose_queries (self): + def __expose_queries (self): # compute variables to expose to the template env = {} # expose the json definition of all queries @@ -138,5 +139,9 @@ class Page: def add_js_chunks (self):pass @to_prelude def add_css_chunks (self):pass - @to_prelude - def prelude_env (self):pass + + # prelude_env also does expose_queries + def prelude_env (self): + self.__expose_queries() + from_prelude=self.prelude.prelude_env() + return from_prelude