[Zope] problem with python script
complaw@hal-pc.org
complaw@hal-pc.org
Thu, 7 Feb 2002 21:55:26 GMT
I use the fpformat module. The fpformat module is a standard python module, but
you have to import it into Zope. To do that, I created a subdirectory called
"MyModules" in my /lib/python/Products subdirectory and placed the fpformat.py
file in there along with an __init__.py script that includes:
allow_module('fpformat')
ModuleSecurityInfo('fpformat').declarePublic('fix')
Once you've done that, then you can use the following code in your python script
to format the float variables:
fpformat.fix(my_float_variable, 2)
Hope that helps,
Ron
> I am having a horrible time with a python script. The idea is to get a
> dollars-and-cents formatted string from the 3.87987234233e-1234 type string
> that the Sybase server is returning. The python script looks like this:
> ---
> final = (float(int(float(number[0:10]) * 100)) / 100)
>
> return final
> ---
> with one parameter (number)
>
> when I call it with either:
> <dtml-call expr="numberTrim(number=cur_bal)">
> or
> <dtml-var expr="numberTrim(number=cur_bal)">
>
> I get:
> Error Type: TypeError
> Error Value: unsliceable object
>
> if I use the "test" at the top and enter a value it works fine and if I
> hard code a value it works as well. The only time it WON'T work is when
> it's called with the cur_bal variable. Has anybody ran into this before?
>
> Thanks,
>
> Rick
>
>
>
>
> _______________________________________________
> 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 )
>