[ZPT] simple condition statement
Fabiano Weimar dos Santos
fabiano@x3ng.com.br
15 Jun 2002 12:35:16 -0300
--=-YvkW+Km3YAjjywPAMrI+
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi
try
<span tal:define=3D"xyz python:request.get('Year',0)"></span>
if Year does not exist in request, the next parameter ( 0 ) will be
returned. The request implementation is a dict. Thus, you allway can use
.get and .set methods.
bye
Em Sex, 2002-06-14 =E0s 18:17, Daniel Tang escreveu:
>=20
> Hello,
>=20
> 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?
>=20
>=20
>=20
>=20
>=20
>=20
> <!-- Get the year from the form IF it is defined -->
>=20
> <span tal:condition=3D"exists:request/form/Year" tal:define=3D"global Yea=
r
> string:${request/form/Year}"></span>
>=20
>=20
>=20
> <!-- Else set to default value 2001 -->
>=20
> <span tal:condition=3D"not:exists:request/form/Year" tal:define=3D"global=
Year
> string:2001"></span>
>=20
>=20
>=20
>=20
>=20
> Error Type: Undefined
> Error Value: Year not found in 'request/form/Year', at line 12, column 1
>=20
>=20
>=20
> Thanks in advance,
> Daniel
>=20
>=20
>=20
> _______________________________________________
> ZPT mailing list
> ZPT@zope.org
> http://lists.zope.org/mailman/listinfo/zpt
>=20
--=20
Fabiano Weimar dos Santos (Xiru) <fabiano@x3ng.com.br>
X3ng Web Technology <http://www.x3ng.com.br>
--=-YvkW+Km3YAjjywPAMrI+
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Para mais informações veja http://www.gnupg.org
iD8DBQA9C160TqbDpNXhEbERApX6AKDJA90E6t36Q6ujjTs//cT/GhWPSACg1CSW
n2paJCIaW0FGVvEI/Vv69B0=
=SBz7
-----END PGP SIGNATURE-----
--=-YvkW+Km3YAjjywPAMrI+--