view gpp/apache/sg101.wsgi @ 197:2baadae33f2e

Got autocomplete working for the member search. Updated django and ran into a bug where url tags with comma separated kwargs starting consuming tons of CPU throughput. The work-around is to cut over to using spaces between arguments. This is now allowed to be consistent with other tags. Did some query optimization for the news app.
author Brian Neal <bgneal@gmail.com>
date Sat, 10 Apr 2010 04:32:24 +0000
parents 04dcbf008bcc
children 1a09a7bea000
line wrap: on
line source
import os
import sys

OFFLINE = False

sys.path.append('/home/var/django-sites/sg101')
sys.path.append('/home/var/django-sites/sg101/3rdparty')
sys.path.append('/home/var/django-sites/sg101/sg101-trunk')
sys.path.append('/home/var/django-sites/sg101/sg101-trunk/gpp')

os.environ['PYTHON_EGG_CACHE'] = '/home/var/django-sites/sg101/eggs/'


def offline_handler(environ, start_response):
    wsgi_dir = os.path.dirname(__file__)
    sys.path.append(wsgi_dir)

    offline_file = os.path.join(wsgi_dir, '..', 'templates', 'offline.html')
    if os.path.exists(offline_file):
        response_headers = [('Content-type','text/html')]
        response = open(offline_file).read()
    else:
        response_headers = [('Content-type','text/plain')]
        response = 'SG101 website maintenance in progress; please check back soon.'
 
    if environ['REQUEST_METHOD'] == 'GET':
        status = '503 Service Unavailable'
    else:
        status = '405 Method Not Allowed'
    start_response(status, response_headers)
    return [response]


if not OFFLINE:
   os.environ['DJANGO_SETTINGS_MODULE'] = 'gpp.settings'
   import django.core.handlers.wsgi
   application = django.core.handlers.wsgi.WSGIHandler()
else:
   application = offline_handler