Created
July 27, 2010 15:48
-
-
Save gcollazo/492399 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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