[ZPT] simple condition statement

Daniel Tang daniel.tang@chronicle.com
Fri, 14 Jun 2002 17:17:16 -0400 (EDT)


Hello,

I am trying to assign a value to a variable if it was not given in the
request/form variables.  But there is an error if the Year isn't defined,
which occurs on the "exists" condition.  What is the correct way to do
this?






<!-- Get the year from the form IF it is defined -->

<span tal:condition="exists:request/form/Year" tal:define="global Year
string:${request/form/Year}"></span>



<!-- Else set to default value 2001 -->

<span tal:condition="not:exists:request/form/Year" tal:define="global Year
string:2001"></span>





Error Type: Undefined
Error Value: Year not found in 'request/form/Year', at line 12, column 1



Thanks in advance,
Daniel