[ZPT] Evaluating a string?

Philip Kilner phil at xfr.co.uk
Sun Feb 22 09:28:51 EST 2004


Hi List,

I'm looping through a Formulator form, field by field. In my "request" 
are variables called "error_[title]" where title is the field name - say 
"ISBN". I want to display these variables in the form, so I need to call: -

	<tal:block content="request/error_ISBN | nothing" />

However, I'm building up my string using: -

	tal:define="global error_field_name python: 'request/error_' + 
field.get_value('title')"

So rather than explicitly write out the string as in the first example 
above, I want to derive the correct name for the variable as in the 
second example above, and use this to display my data. 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?


-- 

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