[ZPT] simple condition statement

matveev@prime.ru matveev@prime.ru
Mon, 17 Jun 2002 09:38:00 +0600


Hello Daniel,
You can use:

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

or:
<span tal:condition="python:request.get('Year', '')" ...
DT> Hello,

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






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

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



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

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





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



DT> Thanks in advance,
DT> Daniel



DT> _______________________________________________
DT> ZPT mailing list
DT> ZPT@zope.org
DT> http://lists.zope.org/mailman/listinfo/zpt



-- 
Best regards,
 matveev                            mailto:matveev@prime.ru