test media
[auf_skeleton_django.git] / bin / django.wsgi
1 #! .virtualenv/bin/python
2
3 import os
4 import sys
5 import site
6
7 major, minor = sys.version_info
8 PYTHON = "python%s.%s" % (major, minor)
9
10 os.environ['DJANGO_SETTINGS_MODULE'] = '{{ project_name }}.settings.production'
11
12 ROOT_DIR = os.path.abspath(os.path.dirname(__file__))
13 VENV_DIR = os.path.join(ROOT_DIR, '.virtualenv')
14 VENV_PKG_DIR = os.path.join(VENV_DIR, 'lib', PYTHON, 'site-packages')
15
16 sys.path.append(ROOT_DIR)
17
18 # extra site-packages
19 PATHS = (
20     VENV_PKG_DIR,
21 )
22
23 # Remember original sys.path.
24 prev_sys_path = list(sys.path)
25
26 # Add each new site-packages directory.
27 for directory in PATHS:
28     site.addsitedir(directory)
29
30 # Reorder sys.path so new directories at the front.
31 new_sys_path = []
32 for item in list(sys.path):
33     if item not in prev_sys_path:
34         new_sys_path.append(item)
35         sys.path.remove(item)
36 sys.path[:0] = new_sys_path
37
38 from django.core.handlers.wsgi import WSGIHandler
39 application = WSGIHandler()
40 try:
41     from raven.contrib.django.middleware.wsgi import Sentry
42     application = Sentry(application)
43 except:
44     pass