Пример #1
0
def test_peek_path_info():
    env = {"SCRIPT_NAME": "/foo", "PATH_INFO": "/aaa/b///c"}

    assert wsgi.peek_path_info(env) == "aaa"
    assert wsgi.peek_path_info(env) == "aaa"
    assert wsgi.peek_path_info(env, charset=None) == b"aaa"
    assert wsgi.peek_path_info(env, charset=None) == b"aaa"
Пример #2
0
    def test_peek_path_info(self):
        env = {"SCRIPT_NAME": "/foo", "PATH_INFO": "/aaa/b///c"}

        self.assert_equal(wsgi.peek_path_info(env), "aaa")
        self.assert_equal(wsgi.peek_path_info(env), "aaa")
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b"aaa")
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b"aaa")
Пример #3
0
    def test_peek_path_info(self):
        env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

        self.assert_equal(wsgi.peek_path_info(env), 'aaa')
        self.assert_equal(wsgi.peek_path_info(env), 'aaa')
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b'aaa')
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b'aaa')
Пример #4
0
def test_peek_path_info():
    env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

    assert wsgi.peek_path_info(env) == 'aaa'
    assert wsgi.peek_path_info(env) == 'aaa'
    assert wsgi.peek_path_info(env, charset=None) == b'aaa'
    assert wsgi.peek_path_info(env, charset=None) == b'aaa'
Пример #5
0
def test_peek_path_info():
    env = {"SCRIPT_NAME": "/foo", "PATH_INFO": "/aaa/b///c"}

    assert wsgi.peek_path_info(env) == "aaa"
    assert wsgi.peek_path_info(env) == "aaa"
    assert wsgi.peek_path_info(env, charset=None) == b"aaa"
    assert wsgi.peek_path_info(env, charset=None) == b"aaa"
Пример #6
0
    def test_peek_path_info(self):
        env = {
            'SCRIPT_NAME': '/foo',
            'PATH_INFO': '/aaa/b///c'
        }

        self.assert_equal(wsgi.peek_path_info(env), 'aaa')
        self.assert_equal(wsgi.peek_path_info(env), 'aaa')
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b'aaa')
        self.assert_equal(wsgi.peek_path_info(env, charset=None), b'aaa')
Пример #7
0
def test_peek_path_info():
    env = {
        'SCRIPT_NAME': '/foo',
        'PATH_INFO': '/aaa/b///c'
    }

    assert wsgi.peek_path_info(env) == 'aaa'
    assert wsgi.peek_path_info(env) == 'aaa'
    assert wsgi.peek_path_info(env, charset=None) == b'aaa'
    assert wsgi.peek_path_info(env, charset=None) == b'aaa'
 def __call__(self, environ, start_response):
     app = self.get_application(peek_path_info(environ))
     if app is not None:
         pop_path_info(environ)
     else:
         app = self.default_app
     return app(environ, start_response)
Пример #9
0
 def __call__(self, environ, start_response):
     app = self.get_application(peek_path_info(environ))
     if app is not None:
         pop_path_info(environ)
     else:
         app = self.default_app
     return app(environ, start_response)
Пример #10
0
    def app(env, start_response):
        if peek_path_info(env) == "healthcheck":
            _app.config['SERVER_NAME'] = None
        else:
            _app.config['SERVER_NAME'] = config.SERVER_NAME

        return _app(env, start_response)
Пример #11
0
    def __call__(self, environ, start_response):
        my_app = self.instances.get(peek_path_info(environ))

        if my_app is not None:
            pop_path_info(environ)
        else:
            my_app = self.default_app
        return my_app(environ, start_response)
Пример #12
0
 def __call__(self, environ, start_response):
     prefix = wsgi.peek_path_info(environ)
     if prefix != "local":
         return self.default_app(environ, start_response)
     _ = wsgi.pop_path_info(environ)
     cid = wsgi.pop_path_info(environ)
     store_app = _local_store_app(cid)
     return store_app(environ, start_response)
Пример #13
0
    def app(env, start_response):
        from entropealabs import config
        from entropealabs.app import App
        _app = App()
        if peek_path_info(env) == "healthcheck":
            _app.config['SERVER_NAME'] = None
        else:
            _app.config['SERVER_NAME'] = config.SERVER_NAME

        return _app(env, start_response)
Пример #14
0
 def attribs(environ, start_response):
     method = environ[REQUEST_METHOD]
     if method == 'GET':
         if peek_path_info(environ):
             return attrib_values
         else:
             return attrib_names
     else:
         return Response('Method {} Not Allowed'.format(method),
                         '405 Method Not Allowed')
Пример #15
0
 def get_app(self, environ):
     prefix = peek_path_info(environ)
     if prefix == 'health':
         if not self._health_app:
             self._health_app = self._make_health_app()
         return self._health_app
     elif prefix not in self._app_instances:
         app = self.create_app(prefix)
         if not app:
             return self.default_app
         self._app_instances[prefix] = app
     return self._app_instances[prefix]
Пример #16
0
 def data(environ, start_response):
     method = environ[REQUEST_METHOD]
     if method == 'GET':
         if peek_path_info(environ):
             return get_data
         else:
             return search_data
     elif method == 'POST':
         return insert_data
     else:
         return Response('Method {} Not Allowed'.format(method),
                         '405 Method Not Allowed')
Пример #17
0
 def wsgi_app(self, environ, start_response):
     request = Request(environ)
     adapter = self.url_map.bind_to_environ(request.environ)
     try:
         endpoint, values = adapter.match()
         if endpoint in ['file', 'root_file']:
             return self.serve_file(environ, start_response, endpoint, **values)
         elif endpoint in ['api', 'upload']:
             response = getattr(self, 'on_' + endpoint)(request, **values)
     except HTTPException, e:
         if peek_path_info(environ) == 'ext':
             response = self.on_ext(request)
         else:
             response = e
Пример #18
0
 def wsgi_app(self, environ, start_response):
     request = Request(environ)
     adapter = self.url_map.bind_to_environ(request.environ)
     try:
         endpoint, values = adapter.match()
         if endpoint in ['file', 'root_file']:
             return self.serve_file(environ, start_response, endpoint,
                                    **values)
         elif endpoint in ['api', 'upload']:
             response = getattr(self, 'on_' + endpoint)(request, **values)
     except HTTPException, e:
         if peek_path_info(environ) == 'ext':
             response = self.on_ext(request)
         else:
             response = e
Пример #19
0
 def wsgi_app(self, environ, start_response):
     if self.check_admin():
         request = Request(environ)
         adapter = self.url_map.bind_to_environ(request.environ)
         try:
             endpoint, values = adapter.match()
             if endpoint in ["file", "root_file"]:
                 return self.serve_file(environ, start_response, endpoint, **values)
             elif endpoint in ["api", "upload"]:
                 response = getattr(self, "on_" + endpoint)(request, **values)
         except HTTPException, e:
             if peek_path_info(environ) == "ext":
                 response = self.on_ext(request)
             else:
                 response = e
         return response(environ, start_response)
Пример #20
0
 def __call__(self, environ, start_response):
     jam.context.environ = environ
     request = JamRequest(environ)
     adapter = self.url_map.bind_to_environ(request.environ)
     try:
         endpoint, values = adapter.match()
         if endpoint in ['file', 'root_file']:
             result = self.serve_file(environ, start_response, endpoint, **values)
             return result
         elif endpoint in ['api', 'upload']:
             response = getattr(self, 'on_' + endpoint)(request, **values)
     except HTTPException as e:
         if peek_path_info(environ) == 'ext':
             response = self.on_ext(request)
         else:
             response = e
     jam.context.session = None
     return response(environ, start_response)
Пример #21
0
    def __call__(self, environ, start_response):
        path_prefix = peek_path_info(environ)
        self._log.debug("Base application __call__ path prefix: '%s'",
                        path_prefix)

        if path_prefix and path_prefix not in self.PREFIX_BLACKLIST:
            app = self.get_application(path_prefix)
            if app is not None:
                pop_path_info(environ)
            else:
                self._log.debug("No IQR application registered for prefix: "
                                "'%s'", path_prefix)
                app = NotFound()
        else:
            self._log.debug("No prefix or prefix in blacklist. "
                            "Using dispatcher app.")
            app = self.wsgi_app

        return app(environ, start_response)
Пример #22
0
    def __call__(self, environ, start_response):
        path_prefix = peek_path_info(environ)
        self._log.debug("Base application __call__ path prefix: '%s'",
                        path_prefix)

        if path_prefix and path_prefix not in self.PREFIX_BLACKLIST:
            app = self.get_application(path_prefix)
            if app is not None:
                pop_path_info(environ)
            else:
                self._log.debug("No IQR application registered for prefix: "
                                "'%s'", path_prefix)
                app = NotFound()
        else:
            self._log.debug("No prefix or prefix in blacklist. "
                            "Using dispatcher app.")
            app = self.wsgi_app

        return app(environ, start_response)
Пример #23
0
 def __call__(self, environ, start_response):
     jam.context.environ = environ
     request = JamRequest(environ)
     if self.max_content_length > 0:
         request.max_content_length = 1024 * 1024 * self.max_content_length
     adapter = self.url_map.bind_to_environ(request.environ)
     try:
         endpoint, values = adapter.match()
         if endpoint in ['file', 'root_file']:
             result = self.serve_file(environ, start_response, endpoint, **values)
             return result
         elif endpoint in ['api', 'upload']:
             response = getattr(self, 'on_' + endpoint)(request, **values)
     except HTTPException as e:
         if peek_path_info(environ) == 'ext':
             response = self.on_ext(request)
         else:
             response = e
     jam.context.session = None
     return response(environ, start_response)
Пример #24
0
    def __call__(self, environ, start_response):
        host = environ['HTTP_HOST']
        subdomain = self._subdomain(host)
        path = peek_path_info(environ)

        if subdomain in self.subdomains:
            app = self.get_application_by_subdomain(subdomain)
        else:
            app = self.get_application_by_path(path)

        if app is None:
            app = self.default_instances.get(subdomain)
            if app is None:
                app = self.default_app()
                self.setup_login_manager(app)
                self.default_instances[subdomain] = app

        if path in self.strip_paths:
            pop_path_info(environ)

        return app(environ, start_response)
Пример #25
0
 def __call__(self, environ, start_response):
     if peek_path_info(environ) == 'api':
         return self.backend_app(environ, start_response)
     else:
         return self.frontend_app(environ, start_response)
Пример #26
0
def test_peek_path_info():
    """Test path info peeking in wrappers and utils"""
    env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

    assert peek_path_info(env) == 'aaa'
    assert peek_path_info(env) == 'aaa'
Пример #27
0
    def test_peek_path_info(self):
        env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

        assert wsgi.peek_path_info(env) == 'aaa'
        assert wsgi.peek_path_info(env) == 'aaa'
Пример #28
0
def test_peek_path_info():
    """Test path info peeking in wrappers and utils"""
    env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

    assert peek_path_info(env) == 'aaa'
    assert peek_path_info(env) == 'aaa'
Пример #29
0
    def test_peek_path_info(self):
        env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/aaa/b///c'}

        assert wsgi.peek_path_info(env) == 'aaa'
        assert wsgi.peek_path_info(env) == 'aaa'
Пример #30
0
def try_():
    return peek_path_info(request.environ)
Пример #31
0
 def __call__(self, environ, start_response):
     app = self.get_application(peek_path_info(environ))
     pop_path_info(environ)
     return app(environ, start_response)
Пример #32
0
def healthcheck(app, env):
    if peek_path_info(env) == "healthcheck":
        app.config['SERVER_NAME'] = None
    else:
        app.config['SERVER_NAME'] = config.SERVER_NAME