pngtile/wsgi.py
changeset 103 1a6a6957197d
parent 93 581cdb831b32
--- a/pngtile/wsgi.py	Mon Jan 25 22:11:10 2010 +0200
+++ b/pngtile/wsgi.py	Tue Jan 26 01:26:05 2010 +0200
@@ -8,19 +8,31 @@
 from pngtile import handlers
 
 
-@responder
-def application (env, start_response) :
+class WSGIApplication (object) :
     """
-        Main WSGI entry point.
-
-        This is wrapped with werkzeug, so we can return a Response object
+        Simple WSGI application invoking the werkzeug handlers
     """
 
-    req = Request(env, start_response)
-    
-    try :
-        return handlers.handle_req(req)
+    def __init__ (self, cache=None) :
+        """
+            Use given cache if any
+        """
 
-    except exceptions.HTTPException, e :
-        return e
+        self.cache = cache
 
+    @responder
+    def __call__ (self, env, start_response) :
+        """
+            Main WSGI entry point.
+
+            This is wrapped with werkzeug, so we can return a Response object
+        """
+
+        req = Request(env, start_response)
+        
+        try :
+            return handlers.handle_req(req, self.cache)
+
+        except exceptions.HTTPException, e :
+            return e
+