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