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