[Zope] Converting a string to an int

Michel Pelletier michel@digicool.com
Mon, 30 Aug 1999 23:46:33 -0400


Timothy Grant wrote:
> 
> Hi,
> 
> I'm working with a form that allows users to enter quantities. Into a
> table.
> 
> on the next form, if I use <dtml-var "_[Category + '_qty']"> I get the
> value from the previous form exactly as I had planned--sortof. I then
> proceeded to do some calculations based on this variable and was told
> that I couldn't because it was a string. No problem thought I, I'll
> convert it to an integer and I used the following code to do so.
> 
> <dtml-call "REQUEST.set('qty', _.string.atoi(_[Category + '_qty']))">
> 

This is way too much effort. ;) Just name the form element:

<input type=whatever name="Category:int"...>

and ZPublisher will turn it into an int for you.

-Michel