index.cgi
changeset 134 fbccc1648d79
parent 133 088aa2da1340
--- a/index.cgi	Mon Feb 16 01:03:23 2009 +0200
+++ b/index.cgi	Mon Feb 16 02:09:14 2009 +0200
@@ -6,30 +6,22 @@
 
 def error () :
     """
-        Dumps out a raw traceback of the current exception to stdout, call from except
-    """
+        Dumps out a raw traceback of the current exception to stdout, call from except.
 
-    import traceback, sys
+        Used for low-level ImportError's
+    """
     
-    # HTTP headers
-    sys.stdout.write('Status: 500 Internal Server Error\r\n')
-    sys.stdout.write('Content-type: text/html\r\n')
+    # if this import fails, we're doomed
+    import sys, error
+    
+    # format info
+    status, content_type, body = error.build_error()
+    
+    # HTTP headers+body
+    sys.stdout.write('Status: %s\r\n' % status)
+    sys.stdout.write('Content-type: %s\r\n' % content_type)
     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()))
+    sys.stdout.write(body)
     
 def main () :
     """
@@ -37,11 +29,11 @@
     """
 
     try :
-        from qmsk.web import wsgi, cgi_main
-        import urls
+        from qmsk.web import cgi_main
+        import wsgi
 
         # create app
-        app = wsgi.Application(urls.mapper)
+        app = wsgi.Application()
         
         # run once
         cgi_main.run(app)