Mercurial > public > madeira
comparison mysite/apache/madeira.wsgi @ 26:efb2da0b5d10
Merging the django1.3 branch into trunk.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 30 Mar 2011 00:16:32 +0000 |
parents | a411e22d73be |
children | 903260593491 |
comparison
equal
deleted
inserted
replaced
21:f3052378ab47 | 26:efb2da0b5d10 |
---|---|
1 import os | 1 import os |
2 import sys | 2 import sys |
3 | 3 |
4 OFFLINE = False | |
5 | |
4 sys.path.append('/home/var/django-sites/madeira/django-trunk') | 6 sys.path.append('/home/var/django-sites/madeira/django-trunk') |
5 sys.path.append('/home/var/django-sites/madeira/madeira-trunk') | 7 sys.path.append('/home/var/django-sites/madeira/madeira-trunk') |
8 sys.path.append('/home/var/django-sites/madeira/madeira-trunk/mysite') | |
6 os.environ['PYTHON_EGG_CACHE'] = '/home/var/django-sites/madeira/eggs/' | 9 os.environ['PYTHON_EGG_CACHE'] = '/home/var/django-sites/madeira/eggs/' |
7 os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' | |
8 | 10 |
9 import django.core.handlers.wsgi | |
10 | 11 |
11 application = django.core.handlers.wsgi.WSGIHandler() | 12 def offline_handler(environ, start_response): |
13 wsgi_dir = os.path.dirname(__file__) | |
14 sys.path.append(wsgi_dir) | |
15 | |
16 offline_file = os.path.join(wsgi_dir, '..', 'templates', 'offline.html') | |
17 if os.path.exists(offline_file): | |
18 response_headers = [('Content-type','text/html')] | |
19 response = open(offline_file).read() | |
20 else: | |
21 response_headers = [('Content-type','text/plain')] | |
22 response = 'themadeira.net website maintenance in progress; please check back soon.' | |
23 | |
24 if environ['REQUEST_METHOD'] == 'GET': | |
25 status = '503 Service Unavailable' | |
26 else: | |
27 status = '405 Method Not Allowed' | |
28 start_response(status, response_headers) | |
29 return [response] | |
30 | |
31 | |
32 if not OFFLINE: | |
33 os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' | |
34 import django.core.handlers.wsgi | |
35 application = django.core.handlers.wsgi.WSGIHandler() | |
36 else: | |
37 application = offline_handler |