annotate mysite/apache/madeira.wsgi @ 25:186c30a29be4 django1.3

Updating the madeira.wsgi file; added a robots.txt.
author Brian Neal <bgneal@gmail.com>
date Wed, 30 Mar 2011 00:00:58 +0000
parents a411e22d73be
children 903260593491
rev   line source
bgneal@2 1 import os
bgneal@2 2 import sys
bgneal@2 3
bgneal@25 4 OFFLINE = False
bgneal@25 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@25 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@25 12 def offline_handler(environ, start_response):
bgneal@25 13 wsgi_dir = os.path.dirname(__file__)
bgneal@25 14 sys.path.append(wsgi_dir)
bgneal@25 15
bgneal@25 16 offline_file = os.path.join(wsgi_dir, '..', 'templates', 'offline.html')
bgneal@25 17 if os.path.exists(offline_file):
bgneal@25 18 response_headers = [('Content-type','text/html')]
bgneal@25 19 response = open(offline_file).read()
bgneal@25 20 else:
bgneal@25 21 response_headers = [('Content-type','text/plain')]
bgneal@25 22 response = 'themadeira.net website maintenance in progress; please check back soon.'
bgneal@25 23
bgneal@25 24 if environ['REQUEST_METHOD'] == 'GET':
bgneal@25 25 status = '503 Service Unavailable'
bgneal@25 26 else:
bgneal@25 27 status = '405 Method Not Allowed'
bgneal@25 28 start_response(status, response_headers)
bgneal@25 29 return [response]
bgneal@25 30
bgneal@25 31
bgneal@25 32 if not OFFLINE:
bgneal@25 33 os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
bgneal@25 34 import django.core.handlers.wsgi
bgneal@25 35 application = django.core.handlers.wsgi.WSGIHandler()
bgneal@25 36 else:
bgneal@25 37 application = offline_handler