[Zope] Tricky usage of string to integer conversion
Brian K. Holdsworth
bhold@awod.com
Tue, 7 Mar 2000 08:33:29 -0500
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