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

Jean-Francois.Doyon@CCRS.NRCan.gc.ca Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Wed, 11 Sep 2002 11:19:25 -0400


Hello,

Thanks for this.  The reason I need to do the int() is because the
underlying data is float is was getting 123.0 ... And I don't want the
decimals to show at all.

Mind you no matter how I do it, I can't seem to get the int() and "null="
functioning properly together.

Of course, this could be because if the database contains an "empty" value
of some kind, it can't be converted to an int ... Which would suggest that
Zope is evaluating the expression before testing the "emptyness" of the
resulting value, which I guess makes sense, but is a bit of a pain in the
butt :)

Ah well,

Thanks for the help anyways!

J.F.

-----Original Message-----
From: Passin,Thomas B. (Tom) [mailto:tpassin@mitretek.org]
Sent: Tuesday, September 10, 2002 5:43 PM
To: zope@zope.org
Subject: RE: [Zope] Question about dtml-var, "null=", and data types


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

 _.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.  

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="N/A", since the argument of null must be a string.

Cheers,

Tom P

_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )