-
Notifications
You must be signed in to change notification settings - Fork 0
/
django.wsgi
executable file
·37 lines (29 loc) · 1.39 KB
/
django.wsgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
import os
import site
PROJECT_NAME = 'testproject'
TLD = 'com'
PYTHON_VERSION = '2.6'
# set old sys.path
prev_sys_path = list(sys.path)
# site packages from virtualenv added to sys.path
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
sitesdir = '%(PROJECT_ROOT)s/env-%(PROJECT_NAME)s/lib/python%(PYTHON_VERSION)s/site-packages' % {'PROJECT_ROOT': PROJECT_ROOT,
'PROJECT_NAME': PROJECT_NAME,
'TLD': TLD,
'PYTHON_VERSION': PYTHON_VERSION}
site.addsitedir(sitesdir)
# website added to sys.path
sys.path.append(PROJECT_ROOT)
## reorder sys.path so that virtualenv packages show up first and are thereby 'leading'
# get a list of 'new' items
new_sys_path = [p for p in sys.path if p not in prev_sys_path]
# remove 'new' items to add them to front
for item in new_sys_path:
sys.path.remove(item)
sys.path[0:0] = new_sys_path
#sys.path[0:0] = ['/Library/Python/2.6/site-packages/PIL']
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % PROJECT_NAME
os.environ['PYTHON_EGG_CACHE'] = '/tmp' if os != 'nt' else 'C:\Temp'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()