﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
12056	update to Apache/mod_wsgi documentation	mgbelisle	nobody	"The current documentation for Apache/mod_wsgi deployment has this as an example apache.wsgi file:

{{{
import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
}}}

Even though the above works just fine, since the django.core.management contains the setup_environment() function, which sets the environment variables in a more standard way, I suggest that we change that part of the documentation to say this:

{{{
import inspect
import os
import sys


apache_dir = os.path.dirname(os.path.realpath(inspect.getfile(inspect.currentframe())))
project_dir = os.path.dirname(apache_dir)
if project_dir not in sys.path:
    sys.path.append(project_dir)

import settings
from django.core.management import setup_environ

setup_environ(settings)

from django.core.handlers.wsgi import WSGIHandler

application = WSGIHandler()
}}}

I tested out the above configuration with python 2.6.3 and it worked well.  I don't know though, maybe finding the current directory then importing the settings is overly complicated.  I'll let you decide.

Thanks,
mgbelisle"	Cleanup/optimization	closed	Core (Other)	1.1	Normal	fixed	mod_wsgi, setup_environ		Design decision needed	0	0	0	0	0	0
