Skip to content

Instantly share code, notes, and snippets.

@nveid
Created October 10, 2012 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save nveid/3862745 to your computer and use it in GitHub Desktop.
Save nveid/3862745 to your computer and use it in GitHub Desktop.
class2go.wsgi
import os, sys
import site
# Remember original sys.path.
prev_sys_path = list(sys.path)
# we add currently directory to path and change to it
pwd = os.path.dirname(os.path.abspath(__file__))
os.chdir(pwd)
sys.path = [pwd] + sys.path
#
# find the site-packages within the local virtualenv
for python_dir in os.listdir('lib'):
site_packages_dir = os.path.join('lib', python_dir, 'site-packages')
if os.path.exists(site_packages_dir):
site.addsitedir(os.path.abspath(site_packages_dir))
# Reorder sys.path so new directories at the front.
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
sys.path.append('/var/www/clients/client4/web102/class2go/main')
sys.path.append('/var/www/clients/client4/web102/class2go')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
# now start django
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
@sefk
Copy link

sefk commented Oct 10, 2012

cool, thanks for posting back. I'll put this in the core c2g but on this so when we get around to s/bitnami/ubuntu/g we can use this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment