| author | ymh <ymh.work@gmail.com> |
| Mon, 22 Oct 2012 17:29:44 +0200 | |
| changeset 258 | 0368e86e4cbd |
| parent 83 | 1c4729b3dac1 |
| permissions | -rw-r--r-- |
| 22 | 1 |
import os |
2 |
import sys |
|
3 |
import site |
|
4 |
||
| 0 | 5 |
|
|
83
1c4729b3dac1
Correction bug #20. The solution is mainly to make sure that the index is recalculated
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
6 |
|
| 0 | 7 |
def application(environ, start_response): |
8 |
||
9 |
global g_env_set |
|
10 |
||
11 |
if 'g_env_set' not in globals() or not g_env_set: |
|
12 |
os.environ['DJANGO_SETTINGS_MODULE'] = environ['DJANGO_SETTINGS_MODULE'] |
|
13 |
||
14 |
prev_sys_path = list(sys.path) |
|
15 |
||
16 |
sys.path.append(environ['PROJECT_PATH']) |
|
| 22 | 17 |
for path in environ.get('PYTHON_PATH', "").split(os.pathsep):
|
| 0 | 18 |
if path: |
| 23 | 19 |
site.addsitedir(path) #@UndefinedVariable |
| 0 | 20 |
|
21 |
new_sys_path = [] |
|
22 |
for item in list(sys.path): |
|
23 |
if item not in prev_sys_path and item not in new_sys_path: |
|
24 |
new_sys_path.append(item) |
|
25 |
sys.path.remove(item) |
|
26 |
sys.path[:0] = new_sys_path |
|
27 |
g_env_set = True |
|
28 |
||
29 |
import django.core.handlers.wsgi |
|
30 |
||
31 |
_application = django.core.handlers.wsgi.WSGIHandler() |
|
32 |
||
|
83
1c4729b3dac1
Correction bug #20. The solution is mainly to make sure that the index is recalculated
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
33 |
if environ.get('PYDEV_DEBUG', "False").lower() in ["true", "1", "t"]:
|
|
1c4729b3dac1
Correction bug #20. The solution is mainly to make sure that the index is recalculated
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
34 |
import pydevd #@UnresolvedImport |
|
1c4729b3dac1
Correction bug #20. The solution is mainly to make sure that the index is recalculated
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
35 |
pydevd.settrace(suspend=False) |
|
1c4729b3dac1
Correction bug #20. The solution is mainly to make sure that the index is recalculated
ymh <ymh.work@gmail.com>
parents:
23
diff
changeset
|
36 |
|
| 0 | 37 |
return _application(environ, start_response) |
38 |