1 | # -*- coding: utf-8 -*-
|
---|
2 |
|
---|
3 | import os
|
---|
4 | import site
|
---|
5 | import sys
|
---|
6 |
|
---|
7 |
|
---|
8 | # You probably will need to change these paths to match your deployment,
|
---|
9 | # most likely because of the Python version you are using.
|
---|
10 | ALLDIRS = [
|
---|
11 | '/home/pootle/env/lib/python2.7/site-packages',
|
---|
12 | '/home/pootle/env/lib/python2.7/site-packages/pootle/apps',
|
---|
13 | ]
|
---|
14 |
|
---|
15 | # Remember original sys.path.
|
---|
16 | prev_sys_path = list(sys.path)
|
---|
17 |
|
---|
18 | # Add each new site-packages directory.
|
---|
19 | for directory in ALLDIRS:
|
---|
20 | site.addsitedir(directory)
|
---|
21 |
|
---|
22 | # Reorder sys.path so new directories at the front.
|
---|
23 | new_sys_path = []
|
---|
24 |
|
---|
25 | for item in list(sys.path):
|
---|
26 | if item not in prev_sys_path:
|
---|
27 | new_sys_path.append(item)
|
---|
28 | sys.path.remove(item)
|
---|
29 |
|
---|
30 | sys.path[:0] = new_sys_path
|
---|
31 |
|
---|
32 | # Set the Pootle settings module as DJANGO_SETTINGS_MODULE.
|
---|
33 | os.environ['DJANGO_SETTINGS_MODULE'] = 'pootle.settings'
|
---|
34 |
|
---|
35 |
|
---|
36 | # Set the WSGI application.
|
---|
37 | def application(environ, start_response):
|
---|
38 | """Wrapper for Django's WSGIHandler().
|
---|
39 |
|
---|
40 | This allows to get values specified by SetEnv in the Apache
|
---|
41 | configuration or interpose other changes to that environment, like
|
---|
42 | installing middleware.
|
---|
43 | """
|
---|
44 | try:
|
---|
45 | os.environ['POOTLE_SETTINGS'] = environ['POOTLE_SETTINGS']
|
---|
46 | except KeyError:
|
---|
47 | pass
|
---|
48 |
|
---|
49 | from django.core.wsgi import get_wsgi_application
|
---|
50 | _wsgi_application = get_wsgi_application()
|
---|
51 | return _wsgi_application(environ, start_response) |
---|