#!/usr/bin/python2.5
"""
CGI mode using qmsk.web.cgi
"""
def error () :
"""
Dumps out a raw traceback of the current exception to stdout, call from except
"""
import traceback, sys
# HTTP headers
sys.stdout.write('Status: 500 Internal Server Error\r\n')
sys.stdout.write('Content-type: text/html\r\n')
sys.stdout.write('\r\n')
sys.stdout.write("""\
<html><head><title>500 Internal Server Error</title></head><body>
<h1>Oops!</h1>
<p>
An error occured, which was not logged, and will not be reported to anybody. It might be your fault, or it might be
the programmer's, but it's probably not mine. If you think you really care, you can try poking the administrator of
this site to see if they respond.
</p>
<p>
If you do so, please include the following information:
</p>
<h2>Details:</h2>
<pre>%(traceback)s</pre>
</body></html>
""" % dict(traceback=traceback.format_exc()))
def main () :
"""
Build our wsgi.Application and run
"""
try :
from qmsk.web import wsgi, cgi_main
import urls
# create app
app = wsgi.Application(urls.mapper)
# run once
cgi_main.run(app)
except :
# display error on stdout
error()
if __name__ == '__main__' :
main()