[Zope] passing information to a rendered ZPT from python

Nicolas Évrard nicoe@altern.org
Mon, 12 May 2003 00:50:24 +0200


--EVF5PPMfhYS0aIcm
Content-Type: text/plain; charset=iso-8859-15; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* martin f krafft  [23:13 11/05/03 CEST]:=20
>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 :=20

in your python script :
return context.a_page_template(username=3D'John Doe', list=3D['a' , 'b'])

in your page template :

Hello, I'm <span tal:replace=3D"options/username">Whoever</span>.

And I say :=20
 <span tal:repeat=3D"item options/list">
  <span tal:replace=3D"item">foo</span>
 </span>

--=20
(=B0>  Nicolas =C9vrard
/ )  Li=E8ge - Belgique
^^

--EVF5PPMfhYS0aIcm
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+vtOw1fJ5cz1/+2URAotlAJ0QME2WfE2F7RlGDKYntX05XdAkzQCcDkWn
4xc4brdnMy15ThroR6i2Jng=
=C/M7
-----END PGP SIGNATURE-----

--EVF5PPMfhYS0aIcm--