Hello, It has taken me about 1 day to find out the cause of a Django application working fine with the embedded server and not with mod_wsgi:
I have an application that uses os.listdir(u'some path') that should return a list of unicode strings. This works fine as long as I use the manage.py runserver server. As soon as I deploy on Apache with mod_wsgi, I get the dreaded Caught UnicodeDecodeError while rendering: 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128) for the same piece of code. I discovered that the problem is that the os.listdir() does not return unicode but byte strings although the requested path is unicode. I found out that print(sys.getfilesystemencoding()) at the console prompt produces 'UTF-8' whereas in the failing script ' ANSI_X3.4-1968' (viz ASCII). I now understand why the conversion fails (in that case Python returns a byte string and this is not documented in Python doc). Following the Python doc regarding sys.getfilesystemencoding() which says the value is from nl_langinfo(CODESET). man nl_langinfo says that this value is related to LC_CTYPE. So I tried to export LC_TYPE in /usr/sbin/envvars (Apache file) without success. In fact the only required variable for getfilesystemencoding to return the proper encoding is to set export LC_LANG="fr_FR.UTF-8" (LC_CTYPE="fr_FR.UTF-8" did not work). Please I would advise to stress on that point in the config section of mod_wsgi documentation. Thanks -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
