Skip to content

Instantly share code, notes, and snippets.

@gcollazo
Created July 27, 2010 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcollazo/492399 to your computer and use it in GitHub Desktop.
Save gcollazo/492399 to your computer and use it in GitHub Desktop.
import sys
import site
import os
VIRTUALENV = '/var/virtualenvs/ponysite.example.com/lib/python2.4/site-packages'
WEBAPPS_PATH = '/var/webapps'
prev_sys_path = list(sys.path)
# add the site-packages of our virtualenv as a site dir
site.addsitedir(VIRTUALENV)
# add the app's directory to the PYTHONPATH
sys.path.append(WEBAPPS_PATH)
# reorder sys.path so new directories from the addsitedir show up first
new_sys_path = [p for p in sys.path if p not in prev_sys_path]
for item in new_sys_path:
sys.path.remove(item)
sys.path[:0] = new_sys_path
# import from down here to pull in possible virtualenv django install
os.environ['DJANGO_SETTINGS_MODULE'] = 'pony_site.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment