passing information to a rendered ZPT from python
i have a python script that ends with return getattr(context, 'a_page_template', None).render() this works like a charm, rendering the page template and outputting it as if the python script produced it. however, i am not sure how i can pass some information (e.g. a username) to the page template. so far i have been using the REQUEST object, but that's an ugly hack, and it also doesn't work (see previous post), so i'd like to do it right. how? -- martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck keyserver problems? http://keyserver.kjsl.com/~jharris/keyserver.html get my key here: http://madduck.net/me/gpg/publickey "when faced with a new problem, the wise algorithmist will first attempt to classify it as np-complete. this will avoid many tears and tantrums as algorithm after algorithm fails." -- g. niruta
* martin f krafft [23:13 11/05/03 CEST]:
i have a python script that ends with
return getattr(context, 'a_page_template', None).render()
this works like a charm, rendering the page template and outputting it as if the python script produced it.
however, i am not sure how i can pass some information (e.g. a username) to the page template. so far i have been using the REQUEST object, but that's an ugly hack, and it also doesn't work (see previous post), so i'd like to do it right. how?
I think you can do that : in your python script : return context.a_page_template(username='John Doe', list=['a' , 'b']) in your page template : Hello, I'm <span tal:replace="options/username">Whoever</span>. And I say : <span tal:repeat="item options/list"> <span tal:replace="item">foo</span> </span> -- (°> Nicolas Évrard / ) Liège - Belgique ^^
also sprach Nicolas ?vrard <nicoe@altern.org> [2003.05.12.0050 +0200]:
in your python script : return context.a_page_template(username='John Doe', list=['a' , 'b'])
in your page template :
Hello, I'm <span tal:replace="options/username">Whoever</span>.
yes, this works. thanks! -- martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck keyserver problems? http://keyserver.kjsl.com/~jharris/keyserver.html get my key here: http://madduck.net/me/gpg/publickey an avocado-tone refrigerator would look good on your resume.
participants (2)
-
martin f krafft -
Nicolas Évrard