Opened 16 years ago

Closed 15 years ago

Last modified 13 years ago

#10426 closed (fixed)

Add a description of language environment variales to "How to use Django with Apache and mod_python" doc page

Reported by: daybreaker Owned by: Jacob
Component: Documentation Version: 1.0
Severity: Keywords: i18n unicode utf-8 file path apache mod_python mod_wsgi language environment variable
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hello, I'm a Korean user of Django.

I've suffered from some issues on unicode file paths on mod_python, and finally I found the rescue here.

When you're going to use non-ascii filenames in your Django project running on Apache mod_python, the environment value for LANG should be set properly so that Python's os and os.path module can handle unicode filenames with proper encoding. There was no problem when I run my project with the test server included in Django because the LANG environment variable of my user account was set properly, but on mod_python it wasn't.

I think the official documentation for deployment on mod_python (and maybe mod_wsgi also) should explain how to set the language environment variable properly, for example in this case, using /etc/apache2/envvars.

Attachments (1)

patch_django_10426.diff (1.1 KB ) - added by David Larlet 16 years ago.
My English is very approximative, please review :)

Download all attachments as: .zip

Change History (12)

comment:1 by Jacob, 16 years ago

milestone: 1.0.31.1
Triage Stage: UnreviewedAccepted

comment:2 by Graham Dumpleton, 16 years ago

Not all Apache distributions have a envvars file. This is especially the case with Linux distributions which ignore the Apache Software Foundation (ASF) installation layout and use their own. Don't think Windows has it either, or whether they use same way of setting it anyway.

Whether one could set LANG or LC_LANG using os.environ in a WSGI script file for mod_wsgi would depend on whether they actually need to be seen during Python initialisation or only when files are first loaded by or for Django.

If they must be set before Python is initialised then it may be better to have a configuration directive for mod_wsgi can set it. This does get tricky though as embedded mode of mod_wsgi shares processes with other Apache modules, eg., PHP, so it can be anti social to be overriding these. Also, different Django instances running in different daemon mode processes may need different language settings and so setting it once before Python initialised may not work anyway so definitely need a different way.

Thus, how does LANG and LC_LANG come into play? For mod_wsgi at least, can't they just be set using os.environ in the start of the WSGI script before Django is loaded?

Can more detail about the original problem being addressed perhaps be added here so can suggest what would be the best approach to getting around it.

comment:3 by daybreaker, 16 years ago

I don't know much about mod_wsgi because I haven't used it, but one thing clear is that changing os.environ['LANG'] does not affect the behaviour of Python's os and os.path module on unicode path strings. Setting environment variable must be done before Python interpreter is initialized.

comment:4 by James Bennett, 16 years ago

Owner: changed from nobody to Jacob

comment:5 by Jacob, 16 years ago

Status: newassigned

comment:6 by Jacob, 16 years ago

Resolution: fixed
Status: assignedclosed

(In [10371]) Fixed a whole bunch of small docs typos, errors, and ommissions.

Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528.

Thanks to all the respective authors of those tickets.

comment:7 by David Larlet, 16 years ago

Resolution: fixed
Status: closedreopened

Sorry Jacob but it seems this one hasn't been closed by this commit or I can't find where.

Documentation from http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi#AdditionalTweaking is very useful when you hit this bug.

by David Larlet, 16 years ago

Attachment: patch_django_10426.diff added

My English is very approximative, please review :)

comment:8 by Ramiro Morales, 15 years ago

Has patch: set

comment:9 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: reopenedclosed

(In [11170]) Fixed #10426 -- Added note on language variables required for Apache to survive non-ASCII file uploads. Thanks to daybreaker for the report, and david for the draft text.

comment:10 by Russell Keith-Magee, 15 years ago

(In [11172]) [1.0.X] Fixed #10426 -- Added note on language variables required for Apache to survive non-ASCII file uploads. Thanks to daybreaker for the report, and david for the draft text.

Merge of r11170 from trunk.

comment:11 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top