예제 #1
0
파일: wsgi.py 프로젝트: LJS109/pulsar
 def test_wsgi_handler_404(self):
     start = mock.MagicMock()
     handler = wsgi.WsgiHandler()
     environ = self.request().environ
     response = handler(environ, start)
     self.assertEqual(response.status_code, 404)
     self.assertEqual(start.call_count, 1)
예제 #2
0
 def setup(self, environ=None):
     green_pool = GreenPool()
     cfg = environ['pulsar.cfg']
     echo_app_name = 'echo_%s' % cfg.name
     echo = EchoGreen(echo_app_name, green_pool.wait)
     app = FlaskApp(echo)
     return wsgi.WsgiHandler([GreenWSGI(app, green_pool)])
예제 #3
0
 async def test_wsgi_handler_404(self):
     start = mock.MagicMock()
     handler = wsgi.WsgiHandler()
     request = await test_wsgi_request()
     response = await handler(request.environ, start)
     self.assertEqual(response.status_code, 404)
     self.assertEqual(start.call_count, 1)
예제 #4
0
파일: wrapper.py 프로젝트: RyanKung/pwsgi
 def setup(self, environ=os.environ):
     app = self.getapp()
     middlewares = self.getmiddlemare() + [
         wsgi.wait_for_body_middleware,
         wsgi.middleware_in_executor(app)
     ]
     return wsgi.WsgiHandler(tuple(middlewares))
예제 #5
0
 def test_wsgi_handler(self):
     handler = wsgi.WsgiHandler()
     try:
         yield handler({}, None)
     except Http404:
         pass
     else:
         assert False
예제 #6
0
파일: manage.py 프로젝트: azazel75/pulsar
 def setup(self, environ):
     router = HttpBin('/')
     return wsgi.WsgiHandler([
         ExpectFail('expect'), wsgi.wait_for_body_middleware,
         wsgi.clean_path_middleware, wsgi.authorization_middleware,
         wsgi.MediaRouter('media', ASSET_DIR, show_indexes=True),
         ws.WebSocket('/graph-data', Graph()), router
     ])
예제 #7
0
 def setup(self):
     router = HttpBin('/')
     return wsgi.WsgiHandler([
         wsgi.clean_path_middleware, wsgi.cookies_middleware,
         wsgi.authorization_middleware,
         wsgi.MediaRouter('media', ASSET_DIR),
         ws.WebSocket('/graph-data', Graph()), router
     ])
예제 #8
0
파일: manage.py 프로젝트: robgil/pulsar
 def setup(self, environ):
     '''Called once to setup the list of wsgi middleware.'''
     json_handler = Root().putSubHandler('calc', Calculator())
     middleware = wsgi.Router('/', post=json_handler,
                              accept_content_types=JSON_CONTENT_TYPES)
     response = [wsgi.GZipMiddleware(200)]
     return wsgi.WsgiHandler(middleware=[middleware],
                             response_middleware=response)
예제 #9
0
    def run(self, handler):
        from pulsar.apps import wsgi
        from pulsar.apps.wsgi.middleware import (middleware_in_executor,
                                                 wait_for_body_middleware)
        #       FIXME pulsar clone error, use copy

        wsgi_handler = wsgi.WsgiHandler(
            [wait_for_body_middleware,
             middleware_in_executor(handler)])

        wsgi.WSGIServer(callable=wsgi_handler,
                        bind="{}:{}".format(self.host, self.port)).start()
예제 #10
0
    def setup(self):
        '''This method is called once only to setup the WSGI application
handler as described in :ref:`lazy wsgi handler <wsgi-lazy-handler>`
section. It creates a :ref:`publish/subscribe handler <apps-pubsub>`
and subscribe it to the ``webchat`` channel.'''
        backend = self.cfg.get('backend_server')
        self.pubsub = pubsub.PubSub(backend, encoder=self.encode_message)
        self.pubsub.subscribe('webchat')
        return wsgi.WsgiHandler([
            wsgi.Router('/', get=self.home_page),
            ws.WebSocket('/message', Chat(self.pubsub)),
            wsgi.Router('/rpc', post=Rpc(self.pubsub))
        ])
예제 #11
0
파일: manage.py 프로젝트: robgil/pulsar
    def setup(self, environ):
        '''Called once only to setup the WSGI application handler.

        Check :ref:`lazy wsgi handler <wsgi-lazy-handler>`
        section for further information.
        '''
        cfg = environ['pulsar.cfg']
        loop = environ['pulsar.connection']._loop
        self.store = data.create_store(cfg.data_store, loop=loop)
        pubsub = self.store.pubsub(protocol=WsProtocol())
        channel = '%s_messages' % self.name
        pubsub.subscribe(channel)
        middleware = [wsgi.Router('/', get=self.home_page),
                      ws.WebSocket('/message', PhilosopherWs(pubsub, channel)),
                      wsgi.FileRouter('/favicon.ico', FAVICON),
                      wsgi.MediaRouter('media', ASSET_DIR)]
        return wsgi.WsgiHandler(middleware)
예제 #12
0
 def setup(self, environ):
     return wsgi.WsgiHandler([
         wsgi.Router('/', get=self.home),
         ws.WebSocket('/data', Graph(), parser_factory=self._factory),
         ws.WebSocket('/echo', Echo(), parser_factory=self._factory)
     ])
예제 #13
0
 def setup(self, environ):
     router = Rout('/')
     return wsgi.WsgiHandler([router])
예제 #14
0
 def handler(self):
     website = self.callable
     middleware = website.wsgi_middleware()
     resp_middleware = website.response_middleware()
     return wsgi.WsgiHandler(middleware, resp_middleware)
예제 #15
0
파일: manage.py 프로젝트: robgil/pulsar
 def setup(self, environ):
     return wsgi.WsgiHandler([
         ws.WebSocket('/message', WsMail()),
         wsgi.MediaRouter('/media', ASSET_DIR),
         wsgi.Router('/', get=self.home)
     ])
예제 #16
0
 def setup(self, environ=None):
     return wsgi.WsgiHandler(
         [wait_for_body_middleware,
          middleware_in_executor(routes.app)])
예제 #17
0
def server():
    wm = ws.WebSocket('/', EchoRPC())
    app = wsgi.WsgiHandler(middleware=[wm])
    return wsgi.WSGIServer(callable=app)
예제 #18
0
 def setup(self, environ=None):
     app = FlaskApp()
     return wsgi.WsgiHandler(
         (wsgi.wait_for_body_middleware, wsgi.middleware_in_executor(app)))
예제 #19
0
파일: manage.py 프로젝트: LJS109/pulsar
 def setup(self, environ=None):
     # setup Flask logger
     app = routes.app()
     return wsgi.WsgiHandler(
         [wait_for_body_middleware,
          middleware_in_executor(app)])
예제 #20
0
 def setup(self, environ):
     wm = ws.WebSocket('/', TitanRPC())
     return wsgi.WsgiHandler(middleware=[wm], async=True)
예제 #21
0
 def testWsgiHandler(self):
     hnd = wsgi.WsgiHandler(middleware=(wsgi.authorization_middleware,))
     self.assertEqual(len(hnd.middleware), 1)
     hnd2 = pickle.loads(pickle.dumps(hnd))
     self.assertEqual(len(hnd2.middleware), 1)
예제 #22
0
파일: manage.py 프로젝트: robgil/pulsar
 def setup(self, environ):
     # only post allowed by the JSON RPC handler
     request = [wsgi.Router('/', post=RpcRoot(self.tqname))]
     response = [wsgi.GZipMiddleware(200)]
     return wsgi.WsgiHandler(middleware=request,
                             response_middleware=response)
예제 #23
0
def wsgi_setup():
    return wsgi.WsgiHandler(middleware=[app],
                            response_middleware=[AccessControl()])
예제 #24
0
 def setup(self):
     return wsgi.WsgiHandler([
         wsgi.Router('/', get=self.home),
         ws.WebSocket('/data', Graph()),
         ws.WebSocket('/echo', Echo())
     ])
예제 #25
0
 def setup(self, environ):
     return wsgi.WsgiHandler([Router('/upload/')])