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