bgneal@2: import os bgneal@2: import sys bgneal@2: bgneal@25: OFFLINE = False bgneal@25: bgneal@7: sys.path.append('/home/var/django-sites/madeira/django-trunk') bgneal@7: sys.path.append('/home/var/django-sites/madeira/madeira-trunk') bgneal@25: sys.path.append('/home/var/django-sites/madeira/madeira-trunk/mysite') bgneal@7: os.environ['PYTHON_EGG_CACHE'] = '/home/var/django-sites/madeira/eggs/' bgneal@2: bgneal@2: bgneal@25: def offline_handler(environ, start_response): bgneal@25: wsgi_dir = os.path.dirname(__file__) bgneal@25: sys.path.append(wsgi_dir) bgneal@25: bgneal@25: offline_file = os.path.join(wsgi_dir, '..', 'templates', 'offline.html') bgneal@25: if os.path.exists(offline_file): bgneal@25: response_headers = [('Content-type','text/html')] bgneal@25: response = open(offline_file).read() bgneal@25: else: bgneal@25: response_headers = [('Content-type','text/plain')] bgneal@25: response = 'themadeira.net website maintenance in progress; please check back soon.' bgneal@25: bgneal@25: if environ['REQUEST_METHOD'] == 'GET': bgneal@25: status = '503 Service Unavailable' bgneal@25: else: bgneal@25: status = '405 Method Not Allowed' bgneal@25: start_response(status, response_headers) bgneal@25: return [response] bgneal@25: bgneal@25: bgneal@25: if not OFFLINE: bgneal@25: os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' bgneal@25: import django.core.handlers.wsgi bgneal@25: application = django.core.handlers.wsgi.WSGIHandler() bgneal@25: else: bgneal@25: application = offline_handler