You can run the same Albatross script as a CGI or from mod_python with the following trick:
try:
os.environ['GATEWAY_INTERFACE']
cgi = 1
except:
cgi = 0
from albatross import SimpleSessionFileApp, SessionFileAppContext
if cgi:
from albatross.cgiapp import Request
else:
from albatross.apacheapp import Request
# Page classes, application/context objects, etc here
app = App()
def handler(req):
'''Called from mod_python - turn a mod_python req into an Albatross Request'''
return do_handler(Request(req))
def do_handler(r):
'''Called with an Albatross Request object'''
return app.run(r)
if cgi:
do_handler(Request())