Mercurial > public > sg101
annotate gpp/apache/sg101.wsgi @ 206:272d3a8c98e8
Some minor tweaks made while rebuilding the development database after Ubuntu 10.04 install.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 03 May 2010 02:49:31 +0000 |
parents | 04dcbf008bcc |
children | 1a09a7bea000 |
rev | line source |
---|---|
bgneal@47 | 1 import os |
bgneal@47 | 2 import sys |
bgneal@47 | 3 |
bgneal@50 | 4 OFFLINE = False |
bgneal@47 | 5 |
bgneal@50 | 6 sys.path.append('/home/var/django-sites/sg101') |
bgneal@47 | 7 sys.path.append('/home/var/django-sites/sg101/3rdparty') |
bgneal@47 | 8 sys.path.append('/home/var/django-sites/sg101/sg101-trunk') |
bgneal@47 | 9 sys.path.append('/home/var/django-sites/sg101/sg101-trunk/gpp') |
bgneal@47 | 10 |
bgneal@47 | 11 os.environ['PYTHON_EGG_CACHE'] = '/home/var/django-sites/sg101/eggs/' |
bgneal@47 | 12 |
bgneal@47 | 13 |
bgneal@47 | 14 def offline_handler(environ, start_response): |
bgneal@47 | 15 wsgi_dir = os.path.dirname(__file__) |
bgneal@48 | 16 sys.path.append(wsgi_dir) |
bgneal@47 | 17 |
bgneal@47 | 18 offline_file = os.path.join(wsgi_dir, '..', 'templates', 'offline.html') |
bgneal@47 | 19 if os.path.exists(offline_file): |
bgneal@47 | 20 response_headers = [('Content-type','text/html')] |
bgneal@47 | 21 response = open(offline_file).read() |
bgneal@47 | 22 else: |
bgneal@47 | 23 response_headers = [('Content-type','text/plain')] |
bgneal@47 | 24 response = 'SG101 website maintenance in progress; please check back soon.' |
bgneal@47 | 25 |
bgneal@47 | 26 if environ['REQUEST_METHOD'] == 'GET': |
bgneal@47 | 27 status = '503 Service Unavailable' |
bgneal@47 | 28 else: |
bgneal@47 | 29 status = '405 Method Not Allowed' |
bgneal@47 | 30 start_response(status, response_headers) |
bgneal@47 | 31 return [response] |
bgneal@47 | 32 |
bgneal@47 | 33 |
bgneal@47 | 34 if not OFFLINE: |
bgneal@47 | 35 os.environ['DJANGO_SETTINGS_MODULE'] = 'gpp.settings' |
bgneal@47 | 36 import django.core.handlers.wsgi |
bgneal@47 | 37 application = django.core.handlers.wsgi.WSGIHandler() |
bgneal@47 | 38 else: |
bgneal@47 | 39 application = offline_handler |
bgneal@47 | 40 |