[Zope] Tricky usage of string to integer conversion

Michel Pelletier michel@digicool.com
Tue, 07 Mar 2000 11:37:54 -0800


Other people answered your conversion question, I just wanted to point
out that the ':int' notation is meant for use in qualifying HTTP POSTED
data, like that coming from a form.  For example:

<form>
  <input name="bob:int">
</form>

This will cause ZPublisher to try and turn the value of this element
into an integer.  This is the only place the ':int' notation makes any
sense.  In your example, you have confused this notation with that of
the let tag.

-Michel

"Brian K. Holdsworth" wrote:
> 
> I am trying to do the following:
> 
> <dtml-let x:int="REQUEST.get('prod_config')"
>           item="_[REQUEST.get('prod_id')]"
>           price="item.price_list[x]">
>     <INPUT type="hidden" name="chargetotal" value="<dtml-var price>">
> </dtml-let>
> 
> The prod_config variable is a number (returned as a string) from a SELECT
> list.  The prod_id variable is the id of an object in the same folder as
> this method that has a price_list attribute.  price_list is a list of
> strings representing prices.
> 
> This results in a "Name Error" where Zope cannot find "x".  If I change line
> 3 to this:
> 
>           price="item.price_list['x']">
> 
> it fixes the Name Error, but then I get a "Sequence Index must be an
> integer" error on price_list['x'].  I would have thought the use of "x:int"
> in my <dtml-let> would take care of this issue.  Seems I can't win!
> 
> Does anyone know the correct way to do this lookup?
> 
> Best Regards,
> Brian Holdsworth
> 
> _______________________________________________
> 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 )