[mod_python] mod_python and locale

Prateep Siamwalla teepwalla at yahoo.com
Fri May 18 21:51:21 EST 2001

Hi All,

I've come across a problem with mod_python (2.7.2
compiled with Python 2.0 --with-threads=no) on Linux
(RH 7.0) regarding locale.

the following code (mptest.py):
from mod_python import apache
from locale import setlocale,LC_ALL,format

def handler(req):
    req.content_type = "text/plain"
    a = 123123231.323    
    req.write("The formatted version of the number %s
is %s" % (a,format('%.2f',a,1)))
    return apache.OK

The formatted version of the number 123123231.323 is

Rather than the expected

I don't have any problems with locale formating on
Win98+Apache+Python2.0.  Is this a recognized problem?

I've tried locale formating from the Python 2.0
command line on the Linux box and it yields expected
results ( 123,123,231.32)

I've tried locale formating from the compiled
Python2.0 with no threads binary on the Linux box and
it also yields expected results.

Its only on mod_python am I encountering a lack of
correct formating.

Have others encountered this problem?

Thanks in advance.

Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

More information about the Mod_python mailing list