Source

reviewanywhere / run.wsgi

Full commit
#!/usr/bin/env python
import os, sys
import django.core.handlers.wsgi

"""
Apache settings:

<Directory APP_PATH>
    Order allow,deny
    Allow from all
</Directory>

Alias /APP/static APP_PATH/static/
WSGIDaemonProcess APP user=USER group=GROUP
WSGIProcessGroup APP
WSGIScriptAlias /APP APP_PATH
"""

app_path = os.path.dirname(__file__)

if "settings.py" not in os.listdir(app_path):
    print "Error: settings.py not found in %r" %(app_path)
    sys.exit(1)

(app_parent_dir, app_name) = os.path.split(app_path)

sys.path.append(app_parent_dir)
sys.path.append(app_path)

os.environ['DJANGO_SETTINGS_MODULE'] = app_name + '.settings'

# Set the wsgi application
application = django.core.handlers.wsgi.WSGIHandler()

# Remap stdout to stderr so that writing to stdout doesn't cause
# a 500 internal error.
sys.stdout = sys.stderr