-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apache, mod_wsgi, Enironment Variables #53
Comments
Hm, I wonder if you could simply move the issue from the server (Apache) into the application (wsgi.py). Couldn't you just use envdir's Python API to load the environment variables before Django initializes completely? Note: the used Would that help fix the issue in cookiecutter-django, @pydanny? |
Well, I think as long as you do not want to control any settings from your virtualhost via environemt variables, you are fine. But what about the following situation: You have 2 envdir directories, one for debugging, one for production. You now have 2 options to load these programmatically: But this requires that you are able to set this variable in the virtualhost (or somehwere else) and retrieve this value in python somehow. Because otherwise you will always end upt with 'dev'. This wouled be possible based on the approach in SO, but Graham does not like it. Is there an option c)? |
So just checking where we are: do we agree on the problem? If so, would be be willing to get the Apache Env variables from the request (other than recommended by Graham) |
I've just added support for .env files, a different strategy for storing environment variables. See 01e3f58 The bottom line is: Set the |
Since I see Apache, mod_wsgi, and environment variables are the title of this issue, it behooves me to point out a downstream issue that was opened for cookiecutter-django: cookiecutter/cookiecutter-django#160 |
@pydanny Thanks! I'm a bit sad to see this issue being dragged between that many projects and that some people involved seem to be passive-aggressive about it. That said, it seems to be an issue for some users stuck on Apache so I'll take a look at how to best document it. Probably with the idea of having separate |
@jezdez, Sending you a private email. |
I found the following comment "Environment variables for configuration (This won't work with Apache/mod_wsgi)." at pydanny's https://github.com/pydanny/cookiecutter-django.
Since this surprised me, I opened a ticket: cookiecutter/cookiecutter-django#74. Pydanny replied correctly, that any solution for that is outside of the scope of the django project template.
Now I fully understand that the root cause for this issue is NOT related to django-configurations. But as a result, the purpose of django-cofigurations (especially in combination with envdir) is somehow corrupted with mod_wsgi and Apache. So I am wondering, if we can come up with some kind of workaround for the problem.
The root cause is desciribed here: http://httpd.apache.org/docs/2.2/env.html. Grahame Dumpleton has commented on the issue at SO (last anwer): http://stackoverflow.com/questions/19754834/access-apache-setenv-variable-from-django-wsgi-py-file
One workaround is described the the same SO question or also in this post: http://drumcoder.co.uk/blog/2010/nov/12/apache-environment-variables-and-mod_wsgi/. Though Graham had a very clear negative opinion on that. Still would that be a valid option?
Are there any other options? If not so, I would at leat propose to add a section to the cookbook in the docs about mod_wsgi/Apache.
The text was updated successfully, but these errors were encountered: