diff options
author | sean finey <seanius@debian.org> | 2009-02-11 23:14:07 +0100 |
---|---|---|
committer | sean finey <seanius@debian.org> | 2009-02-11 23:14:07 +0100 |
commit | aa62df8715ce930e473733ab0de0bc10ef6446d6 (patch) | |
tree | d177b9cb77d105e7faf2f289c8bef51b1b2094bd /pagehandler.py | |
parent | 965623e3f65f95575daa8cdb822cf88317be7a7d (diff) | |
download | patch-tracker-aa62df8715ce930e473733ab0de0bc10ef6446d6.tar.gz |
mod_python -> wsgi
i hear it's the new black. code change requirements weren't
very big at all, and apparently this will work better/stabler
on lenny systems, so...
Diffstat (limited to 'pagehandler.py')
-rwxr-xr-x | pagehandler.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pagehandler.py b/pagehandler.py index 477f540..f9a293d 100755 --- a/pagehandler.py +++ b/pagehandler.py @@ -1,15 +1,14 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# main (mod_python) request handler for patch-tracking system +# main (wsgi) request handler for patch-tracking system # this handler file basically farms out all its work to the ReqHandler # module, which in turn splits up the request URI and acts accordingly. -from mod_python import apache import os import sys -def handler(req): +def application(env, resp): # the apache config sets a hint of where we are installed, which is # needed in mod_python since cwd is not automatically set try: @@ -19,7 +18,21 @@ def handler(req): pass import patchtracker.ReqHandler as ReqHandler - ReqHandler.Client.req = req + try: + cmdh = ReqHandler.CmdHandler(env) + resp(cmdh.status, cmdh.headers) + return cmdh.output() + except ReqHandler.ReqHandlerException, e: + resp(e.status, [('Content-Type', 'text/html')]) + return ReqHandler.ErrorCmd(str(e), e.status).output() - req.write(ReqHandler.CmdHandler(req).output()) - return apache.OK +if __name__ == '__main__': + from wsgiref import simple_server as ss + print "pagehandler test server running..." + server = ss.WSGIServer( ('',8080), ss.WSGIRequestHandler) + server.set_app(application) + while True: + try: + server.handle_request() + except IOError, e: + print "adsf: ",e |