Commits

Ginés Martínez Sánchez committed 788abc3 Draft

developing wsgi server

Comments (0)

Files changed (2)

ginsfsm/protocols/wsgi/common/wsgi_response.py

     """
     environ = None
 
-    def __init__(self, request, wsgi_server):
+    def __init__(self, request, wsgi_server, application):
         HttpResponse.__init__(self, request)
         self.wsgi_server = wsgi_server
+        self.application = application
 
     def execute(self):
         env = self.get_environment()
         # Call the application to handle the request and write a response
         # TODO: do a multi wsgi-app
         try:
-            app_iter = self.wsgi_server.application(env, start_response)
+            app_iter = self.application(env, start_response)
         except DeferredInterrupt:
             """ A gobj inside his gaplic need
                 to wait for data from another gaplic.

ginsfsm/protocols/wsgi/server/c_wsgi_server.py

 def ac_request(self, event):
     channel = event.source[-1]
     request = event.request
-    response = WsgiResponse(request, self)
+    application = self.select_app(request)
+    response = WsgiResponse(request, self, application)
     self.send_event(channel, 'EV_HTTP_RESPONSE', response=response)
 
 
             self.serversock.getsockname()
         self.server_name = self._get_server_name(self.host)
 
+    def select_app(self, request):
+        # TODO: do a multi-app, application based on url?
+        # con sistema de registro de aplicacion/url
+        # una wsgi-app podria ser la puerta de injección de eventos
+        # sería multi-wsgi-app en paralelo, no en pila como con los wsgi middleware
+        return self.application
+
     def _get_server_name(self, ip):
         """Given an IP or hostname, try to determine the server name."""
         if ip:
 
     def getsockname(self):
         return self.serversock.socket.getsockname()
-