[ZPT] Evaluating a string?

Philip Kilner phil at xfr.co.uk
Sun Feb 22 10:42:31 EST 2004


Hi All,

Answering my own question for posterity:_
> I'm using: -
> 
>     <tal:block content="python:error_field_name" />
> 
> ...but this simply displays the derived string (e.g. 
> "request/error_ISBN", rather than pulling "error_ISBM" out of the 
> "request".
> 
> How do I ask python to /evaluate/ the string?
> 

...and the answer is: -

	<tal:block content="python:path(error_field_name)" />

What I found out since asking the question is: -

- Zope doesn't permit access to the "exec" in Python, which was my first 
line of attack.

- Using python:path(some string) is discussed here: -

	http://www.zopelabs.com/cookbook/1028652735

- If the variable isn't there, you get key errors, so you need: -

	<tal:block tal:condition="exists:python:path(error_message)" 
content="python:path(error_message)"/>

Hope this helps someone...if I never /do/ learn all this stuff it can be 
my epitaph!

-- 

Regards,

PhilK

Email: phil at xfr.co.uk / Voicemail & Facsimile: 07092 070518

  “The basic tool for the manipulation of reality is the manipulation
of words. If you can control the meaning of words, you can control
the people who must use the words.” Philip K. Dick




More information about the ZPT mailing list