Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

More wsgi tweaks

  • Loading branch information...
1 parent a156258 commit 8e669530eec755a8f53623fe24602278bcee9885 @lmorchard committed
Showing with 4 additions and 13 deletions.
  1. +4 −13 wsgi/badger.wsgi
17 wsgi/badger.wsgi
@@ -1,18 +1,16 @@
import os
-from os.path import abspath, dirname, join
-from site import addsitedir
+import site
+import sys
from datetime import datetime
-# redirect sys.stdout to sys.stderr for bad libraries like geopy that uses
-# print statements for optional import exceptions.
+# fix (and potentially others) using stdout
sys.stdout = sys.stderr
# Remember when mod_wsgi loaded this file so we can track it in nagios.
wsgi_loaded =
-# Add the badger dir to the python path so we can import manage.
+# Add the main dir to the python path so we can import manage.
wsgidir = os.path.dirname(__file__)
-sys.path.insert(0, abspath(join(dirname(__file__), "../../")))
site.addsitedir(os.path.abspath(os.path.join(wsgidir, '../')))
# manage adds /apps, /lib, and /vendor to the Python path.
@@ -25,7 +23,6 @@ import django.utils
# Do validate and activate translations like using `./ runserver`.
utility =
command = utility.fetch_command('runserver')
@@ -33,16 +30,10 @@ command.validate()
# This is what mod_wsgi runs.
django_app = django.core.handlers.wsgi.WSGIHandler()
-# Normally we could let WSGIHandler run directly, but while we're dark
-# launching, we want to force the script name to be empty so we don't create
-# any /z links through reverse. This fixes bug 554576.
def application(env, start_response):
- if 'HTTP_X_ZEUS_DL_PT' in env:
- env['SCRIPT_URL'] = env['SCRIPT_NAME'] = ''
env['wsgi.loaded'] = wsgi_loaded
return django_app(env, start_response)
# Uncomment this to figure out what's going on with the mod_wsgi environment.
# def application(env, start_response):
# start_response('200 OK', [('Content-Type', 'text/plain')])

0 comments on commit 8e66953

Please sign in to comment.
Something went wrong with that request. Please try again.