|
Size: 875
Comment:
|
Size: 875
Comment: grrr. Get it right way around!
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 5: | Line 5: |
| from albatross.cgiapp import Request # This will fail if we are not inside mod_python | from albatross.apacheapp import Request # This will fail if we are not inside mod_python |
| Line 8: | Line 8: |
| from albatross.apacheapp import Request | from albatross.cgiapp import Request |
You can run the same Albatross script as a CGI or from mod_python, or even from the command line, with the following trick:
from albatross import SimpleSessionFileApp, SessionFileAppContext
try:
from albatross.apacheapp import Request # This will fail if we are not inside mod_python
cgi = 0
except ImportError:
from albatross.cgiapp import Request
cgi = 1
# 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())