#!/usr/bin/env python """Connector for mod_wsgi. """ import os from os.path import isdir from aspen import website_factory from aspen._configuration import ConfigurationError ROOT = None _application = None def application(environ, start_response): """Define a WSGI callable with the name mod_wsgi expects. mod_wsgi communicates to us in the WSGI environ, so we need this shim to get the website root we want to serve out of httpd.conf. """ global ROOT, _application if _application is None: try: ROOT = environ['aspen.root'] except KeyError: raise ConfigurationError("Please specify aspen.root using SetEnv.") if not isdir(ROOT): raise ConfigurationError("Path does not exist: " + ROOT) _application = website_factory(['--root', ROOT]) return _application(environ, start_response)