import os, sys import site sys.path = [''] + sys.path site.addsitedir('/lib/python2.6/site-packages') sys.stdout = sys.stderr os.environ['DJANGO_SETTINGS_MODULE'] = 'django_site.settings' from django import db from django.conf import settings from django.contrib.sessions.backends.db import SessionStore from django.contrib.auth.models import User from django.core.handlers.wsgi import WSGIRequest def allow_access(environ, host): """ Authentication handler that checks if user is logged in """ # Fake this, allow_access gets a stripped environ environ['wsgi.input'] = None request = WSGIRequest(environ) errors = environ['wsgi.errors'] try: if : return True else: return False except Exception as e: errors.write('Exception: %s\n' % e) return False finally: db.connection.close()