annotate mysite/apache/madeira.wsgi @ 26:efb2da0b5d10

Merging the django1.3 branch into trunk.
author Brian Neal <bgneal@gmail.com>
date Wed, 30 Mar 2011 00:16:32 +0000
parents a411e22d73be
children 903260593491
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@26 33 os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
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