[ZPT] Acquiring PT local context (e.g. state of defines, repeat) within python scripts?

Dieter Maurer dieter@handshake.de
Fri, 27 Dec 2002 20:32:01 +0100


Jeff Kowalczyk wrote at 2002-12-26 15:30 -0500:
 > I'm making every effort to keep logic out of the Page Templates I'm writing, creating many
 > python scripts in the process. The parameter lists to some of the scripts called with
 > python:here.myScript() get pretty long and complex.
 > 
 > I'd like to try acquisition in the python scripts to get at the Page Template execution
 > 'context', such as the current tal:defined variables, the current state of the
 > batch/repeats, etc., without making an enormous parameter lists. Something like the
 > following pseudocode (which fails with an attribute error, obviously):
You cannot use acquisition for this.

But you may try the predefined TALES variable "CONTEXTS" (and pass it
explicitely into your Page Templates).
It is a dictionary containing the known variables.

I am not sure whether you will be able to access all keys from
TTW code (such as "loop variables") but you can give it a try.


Dieter