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