Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 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: UI/UX:

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 5 years ago.
My English is very approximative, please review :)

Download all attachments as: .zip

Change History (12)

comment:1 Changed 5 years ago by jacob

  • milestone changed from 1.0.3 to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by grahamd

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 Changed 5 years ago by daybreaker

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 Changed 5 years ago by ubernostrum

  • Owner changed from nobody to jacob

comment:5 Changed 5 years ago by jacob

  • Status changed from new to assigned

comment:6 Changed 5 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

(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 Changed 5 years ago by david

  • Resolution fixed deleted
  • Status changed from closed to reopened

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.

Changed 5 years ago by david

My English is very approximative, please review :)

comment:8 Changed 5 years ago by ramiro

  • Has patch set

comment:9 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

(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 Changed 5 years ago by russellm

(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 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.