0
|
1 |
import os, sys, site
|
|
2 |
|
|
3 |
def application(environ, start_response):
|
|
4 |
|
|
5 |
global g_env_set
|
|
6 |
|
|
7 |
if 'g_env_set' not in globals() or not g_env_set:
|
102
|
8 |
os.environ.setdefault('DJANGO_SETTINGS_MODULE',environ['DJANGO_SETTINGS_MODULE'])
|
0
|
9 |
|
|
10 |
prev_sys_path = list(sys.path)
|
|
11 |
|
|
12 |
sys.path.append(environ['PROJECT_PATH'])
|
|
13 |
for path in environ.get('PYTHON_PATH',"").split(os.pathsep):
|
|
14 |
if path:
|
|
15 |
site.addsitedir(path)
|
|
16 |
|
|
17 |
new_sys_path = []
|
|
18 |
for item in list(sys.path):
|
|
19 |
if item not in prev_sys_path and item not in new_sys_path:
|
|
20 |
new_sys_path.append(item)
|
|
21 |
sys.path.remove(item)
|
|
22 |
sys.path[:0] = new_sys_path
|
|
23 |
g_env_set = True
|
|
24 |
|
|
25 |
import django.core.handlers.wsgi
|
|
26 |
|
|
27 |
_application = django.core.handlers.wsgi.WSGIHandler()
|
|
28 |
|
|
29 |
if environ.get('PYDEV_DEBUG', "False").lower() in ["true", "1", "t"]:
|
|
30 |
import pydevd #@UnresolvedImport
|
|
31 |
pydevd.settrace(suspend=False)
|
|
32 |
|
|
33 |
return _application(environ, start_response)
|
|
34 |
|