[Zope] 3RD REQUEST: PLEASE HELP

Eron Lloyd lloyd@lancaster.lib.pa.us
Mon, 7 Jan 2002 10:16:24 -0500


Ben,

Off the top of my head it seems you are mixing data, logic, and presentation 
unnecessarily. Is what you're trying to accomplish the generation of a style 
sheet value for a font? This to me seems wholly complicated... just browsing 
the code makes me think your error is coming from the "_.int(subtotal)*.05)" 
in the variable assignment. Thats why the exception

Error Type: ValueError
Error Value: invalid literal for int(): 126.0

is raised. You may want to keep "shipping" a float and only coerce it into an 
integer when necessary. That could help.

Perhaps if you explain what you'd ultimately like to do we could find an 
alternate and more simplified way of approaching it.

HTH,

Eron

On Monday 07 January 2002 07:14 am, you wrote:
> Hi;
> I have a form in which I create a variable like this:
>
> <dtml-call "REQUEST.set('shipping',_.int(subtotal)*.05)">
> <input type=hidden name=shipping value=<dtml-var shipping>>
>
> which is successfully used in said form like this:
>
>   <dtml-if shipping>
>    <tr>
>     <td><font style="font: <dtml-var "sizeCalc(15,size(_.None,_))">px
> verdana">Shipping:</font></td>
>     <td><font style="font: <dtml-var "sizeCalc(15,size(_.None,_))">px
> verdana"><dtml-var shipping fmt=dollars-and-cents></font></td>
>    </tr>
>   </dtml-if>
>
> but when I try to render it in the form to which I pass it like this:
>
>   <dtml-if shipping>
>     <tr>
>      <td><font style="font: <dtml-var "sizeCalc(15,size(_.None,_))">px
> verdana">Shipping</font></td>
>      <td>&nbsp;</td>
>      <td>&nbsp;</td>
>      <td><font style="font: <dtml-var "sizeCalc(15,size(_.None,_))">px
> verdana"><dtml-var shipping fmt=dollars-and-cents></font></td>
>     </tr>
>   </dtml-if>
>
> it doesn't render at all! So I try something sneaky like this:
>
>   <dtml-if shipping>
>   <dtml-let shippingit="shipping+0.00">
>     <tr>
>      <td><font style="font: <dtml-var "sizeCalc(15,size(_.None,_))">px
> verdana">Shipping</font></td>
>      <td>&nbsp;</td>
>      <td>&nbsp;</td>
>      <td><font style="font: <dtml-var "sizeCalc(15,size(_.None,_))">px
> verdana"><dtml-var shippingit fmt=dollars-and-cents></font></td>
>     </tr>
>   </dtml-let>
>   </dtml-if>
>
> and I get this error:
>
> Error Type: ValueError
> Error Value: invalid literal for int(): 126.0
>
> I'd just like the stupid thing to show up in dollars-and-cents. Any ideas?
> TIA,
> BenO
>
>
>
> _______________________________________________
> 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 )