Bruno,
It's so old! But helped a lot.
Thank you.
Any way, news about locale?
Best regards,
Daniel Guilhermino
Em quarta-feira, 25 de agosto de 2010 18:03:54 UTC-3, rochacbruno escreveu:
>
> I solved using temporarily this:
>
> def Moeda(valor, formatado=True):
> from locale import setlocale, currency, LC_ALL
> try:
> setlocale(LC_ALL,'pt_BR.UTF-8')
> except:
> setlocale(LC_ALL,'portuguese')
>
> if formatado:
> return 'R$ %s' % currency(valor, grouping=True, symbol=False)
> else:
> return currency(valor, grouping=False,
> symbol=False).replace(',','')
>
>
> >>> Moeda(10000)
> R$ 10.000,00
>
> This will be okay until I have more apps running on the same server, now I
> have just one.
>
> I am trying to figure out the best way
>
> 2010/8/25 Bruno Rocha <[email protected] <javascript:>>
>
>> Massimo,
>>
>> What is your recomendation to deal with currency in web2py?
>>
>> 2010/8/25 Bruno Rocha <[email protected] <javascript:>>
>>
>> Look at
>>> http://code.google.com/p/python-money/source/browse/trunk/money/Money.py
>>>
>>> Python-money does not use "locale"
>>>
>>> 2010/8/25 mdipierro <[email protected] <javascript:>>
>>>
>>> web2py cannot support locale because it is not thread safe, If one app
>>>> changes the locale it would change it for all apps.
>>>>
>>>> On Aug 25, 12:07 am, Bruno Rocha <[email protected]> wrote:
>>>> > Hi,
>>>> >
>>>> > Actually, I am using these methods to work with money formating.
>>>> >
>>>> > some tries with python-money and works very wellhttp://
>>>> code.google.com/p/python-money/
>>>> >
>>>> > and sometimes
>>>> >
>>>> > import locale
>>>> > locale.setlocale(locale.LC_ALL,('pt_BR','UTF8'))>>>
>>>> locale.currency(1090909, grouping=True)
>>>> >
>>>> > 'R$ 1.090.909,00'
>>>> >
>>>> > So I a thinking about, how to include that as a DAL type? exactly in
>>>> > the same way web2py threats with Upload fields, we could have a
>>>> > datatype 'money' working with 'locale'
>>>> >
>>>> >
>>>> db.define_table('product',Field('price','money',locale=('pt_BR','UTF8')))
>>>> > or even declaring locale.setlocale() in the begining of the model file
>>>> >
>>>> > By now I am doing that with 'represent' or directly in views, but,
>>>> > Is there any chance to include that in web2py core?
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> http://rochacbruno.com.br
>>>
>>
>>
>>
>> --
>>
>> http://rochacbruno.com.br
>>
>
>
>
> --
>
> http://rochacbruno.com.br
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.