bin/qmsk-irclogs.cgi
changeset 143 154d2d8ae9c0
parent 140 6db2527b67cf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/qmsk-irclogs.cgi	Sun Sep 13 20:08:16 2009 +0300
@@ -0,0 +1,49 @@
+#!/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.
+
+        Used for low-level ImportError's
+    """
+    
+    import sys
+
+    # if this import fails, we're doomed
+    from qmsk.irclogs import 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(body)
+    
+def main () :
+    """
+        Build our wsgi.Application and run
+    """
+
+    try :
+        from qmsk.web import cgi_main
+        from qmsk.irclogs import wsgi
+
+        # create app
+        app = wsgi.Application()
+        
+        # run once
+        cgi_main.run(app)
+
+    except :
+        # display error on stdout
+        error()
+    
+if __name__ == '__main__' :
+    main()
+