lib/wsgi.py
changeset 46 185504387370
parent 45 e94ab812c0c8
child 47 3d59c9eeffaa
--- a/lib/wsgi.py	Sun Feb 08 03:13:11 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-
-"""
-    WSGI application implementation
-"""
-
-# for error reporting
-import sys, traceback
-
-# for Request/Response
-import http
-
-class Application (object) :
-    """
-        Our WSGI application, implements the wsgi __call__ interface
-    """
-
-    def __init__ (self, handler) :
-        """
-            Initialize to use the given handler for requests
-        """
-
-        self.handler = handler
-    
-    def handle_request (self, env, start_response) :
-        """
-            The actual request handling code
-        """
-
-        # build Request object
-        request = http.Request(env)
-
-        try :
-            # request -> response using our handler
-            response = self.handler.handle_request(request)
-
-        except http.ResponseError, err :
-            # just use the generated response
-            response = err.get_response()
-
-        # send response
-        assert response, "No response"
-        
-        # send response status/headers
-        start_response(response.get_status(), response.get_headers())
-
-        # send respones data
-        yield response.get_data()
-
-    def __call__ (self, env, start_response) :
-        """
-            Wraps handle_request to trap errors
-        """
-
-        try :
-            # passthrough request_handler
-            for chunk in self.handle_request(env, start_response) :
-                yield chunk
-
-        except :
-            # execption info
-            info = sys.exc_info()
-
-            # try and send 500 ISE to browser, if no headers yet...
-            start_response("500 Internal Server Error", [('Content-type', "text/plain; charset=utf8")], info)
-
-            # send traceback
-            yield traceback.format_exc()
-