[Zope] type conversion required?

Martijn Pieters mj@antraciet.nl
Thu, 01 Jul 1999 13:50:17 +0200


At 12:52 01/07/99 , Graham Chiu wrote:
>I would like to save the html product of a database query for subsequent
>recall.
>
>If I have something like this:
>
><!--#in sqlMethod-->
>   <!--#call "REQUEST.set('htmlString',htmlString+PRICE+'</td><td>'+DESCR
>IPTION+'</td><td>)"-->
><!--#/in-->
>
>where PRICE is a numeric field from the database, then I get a typeError
>- presumably because PRICE is numeric and the others are text.
>
>How do I convert PRICE into a string to avoid this problem?

By using the str method of the _ object:

<!--#call "REQUEST.set('htmlString', htmlString + _.str(PRICE) + 
'</td><td>' + DESCRIPTION + '</td><td>)"-->

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------