annotate gpp/apache/sg101.wsgi @ 518:5171a5e9353b

For #194, add a celery task for purging deleted private messages.
author Brian Neal <bgneal@gmail.com>
date Fri, 16 Dec 2011 01:17:35 +0000
parents 5794e3414596
children
rev   line source
bgneal@47 1 import os
bgneal@47 2 import sys
bgneal@511 3 import site
bgneal@511 4
bgneal@47 5
bgneal@50 6 OFFLINE = False
bgneal@47 7
bgneal@511 8 site.addsitedir('/home/var/django-sites/virtualenvs/sg101/lib/python2.5/site-packages')
bgneal@47 9
bgneal@511 10 sys.path.append('/home/var/django-sites/virtualenvs/sg101/sg101')
bgneal@511 11 sys.path.append('/home/var/django-sites/virtualenvs/sg101/sg101/gpp')
bgneal@511 12 sys.path.append('/home/var/django-sites/virtualenvs/sg101/sg101/tools')
bgneal@511 13
bgneal@511 14 os.environ['PYTHON_EGG_CACHE'] = '/home/var/django-sites/virtualenvs/sg101/eggs'
bgneal@511 15 os.environ['CELERY_LOADER'] = 'django'
bgneal@47 16
bgneal@47 17
bgneal@47 18 def offline_handler(environ, start_response):
bgneal@47 19 wsgi_dir = os.path.dirname(__file__)
bgneal@48 20 sys.path.append(wsgi_dir)
bgneal@47 21
bgneal@47 22 offline_file = os.path.join(wsgi_dir, '..', 'templates', 'offline.html')
bgneal@47 23 if os.path.exists(offline_file):
bgneal@47 24 response_headers = [('Content-type','text/html')]
bgneal@47 25 response = open(offline_file).read()
bgneal@47 26 else:
bgneal@47 27 response_headers = [('Content-type','text/plain')]
bgneal@47 28 response = 'SG101 website maintenance in progress; please check back soon.'
bgneal@47 29
bgneal@47 30 if environ['REQUEST_METHOD'] == 'GET':
bgneal@47 31 status = '503 Service Unavailable'
bgneal@47 32 else:
bgneal@47 33 status = '405 Method Not Allowed'
bgneal@47 34 start_response(status, response_headers)
bgneal@47 35 return [response]
bgneal@47 36
bgneal@47 37
bgneal@47 38 if not OFFLINE:
bgneal@499 39 os.environ['DJANGO_SETTINGS_MODULE'] = 'gpp.settings.production'
bgneal@47 40 import django.core.handlers.wsgi
bgneal@47 41 application = django.core.handlers.wsgi.WSGIHandler()
bgneal@47 42 else:
bgneal@47 43 application = offline_handler
bgneal@47 44