[Zope] Question about dtml-var, "null=", and data types

Passin,Thomas B. (Tom) tpassin@mitretek.org
Tue, 10 Sep 2002 17:42:47 -0400


[ Jean-Francois.Doyon]
>=20
> I have a tag as such: <dtml-var DMT_S_E null=3DN/A>
>=20
> DMT_S_E is a variable that comes from a SQL Method with a=20
> PostgreSQL backend. DMT_S_E is of pgsql data-type "float8".
>=20
> Yet, for some reason, when I do <dtml-var "_.int(DMT_S_E)"=20
> null=3DN/A>, I get an error about not being able to convert it=20
> to int. This is where the value is null, and therefore "N/A"=20
> gets displayed.
>=20
> So, does this mean that the "null" value has to be of the=20
> same data-type as the variable itself?=20

 _.int() will convert a string or number to an integer, but a null is
not a string or number.  If you are just displaying the data (as with
dtml-var), you do not really have to convert it into an integer anyway.
This would avoid the problem. =20

If you need to do some formatting, you ought to be able to do it with a
formatting string rather than trying to convert to in integer.

Also, once you work out what you want to do, you will want to use
null=3D"N/A", since the argument of null must be a string.

Cheers,

Tom P