def __call__(self, environ, start_response): assert not environ['wsgi.multiprocess'], ( "Dozer middleware is not usable in a " "multi-process environment") req = Request(environ) req.base_path = req.application_url + self.path if (req.path_info.startswith(self.path+'/') or req.path_info == self.path): req.script_name += self.path req.path_info = req.path_info[len(self.path):] try: return self.dowse(req)(environ, start_response) except Exception as ex: error_text = traceback.format_exc() acceptable_offers = req.accept.acceptable_offers( offers=['text/html', 'application/json'] ) match = acceptable_offers[0][0] if acceptable_offers else None if match != 'application/json': # Strangely, webob.exc.WSGIHTTPException.plain_body replaces newlines # to spaces for plain/text, but replaces "<br/>" tags to newlines. error_text = error_text.replace('\n', '<br/>') return exc.HTTPInternalServerError( str(ex), body_template=error_text )(environ, start_response) else: return self.app(environ, start_response)
def make_request(self): req = Request({ 'PATH_INFO': '/whatevs', 'wsgi.url_scheme': 'http', 'HTTP_HOST': 'localhost' }) req.base_path = '/_dozer' return req
def __call__(self, environ, start_response): assert not environ["wsgi.multiprocess"], "Dozer middleware is not usable in a " "multi-process environment" req = Request(environ) req.base_path = req.application_url + self.path if req.path_info.startswith(self.path + "/") or req.path_info == self.path: req.script_name += self.path req.path_info = req.path_info[len(self.path) :] return self.dowse(req)(environ, start_response) else: return self.app(environ, start_response)
def __call__(self, environ, start_response): assert not environ['wsgi.multiprocess'], ( "Dozer middleware is not usable in a " "multi-process environment") req = Request(environ) req.base_path = req.application_url + '/_profiler' if req.path_info_peek() == '_profiler': return self.profiler(req)(environ, start_response) for regex in self.ignored_paths: if regex.match(environ['PATH_INFO']) is not None: return self.app(environ, start_response) return self.run_profile(environ, start_response)
def __call__(self, environ, start_response): assert not environ['wsgi.multiprocess'], ( "Dozer middleware is not usable in a " "multi-process environment") req = Request(environ) req.base_path = req.application_url + self.path if (req.path_info.startswith(self.path + '/') or req.path_info == self.path): req.script_name += self.path req.path_info = req.path_info[len(self.path):] return self.dowse(req)(environ, start_response) else: return self.app(environ, start_response)
def __call__(self, environ, start_response): assert not environ['wsgi.multiprocess'], ( "Leak middleware is not usable in a " "multi-process environment") if self.inupy_config['ipfilter'] and not check_ipfilter(environ, self.inupy_config['ipfilter']): # then we want to filter on ip and this one failed return self.app(environ, start_response) else: req = Request(environ) req.base_path = req.application_url + self.path if (req.path_info.startswith(self.path+'/') or req.path_info == self.path): req.script_name += self.path req.path_info = req.path_info[len(self.path):] return self.dowse(req)(environ, start_response) else: return self.app(environ, start_response)
def __call__(self, environ, start_response): assert not environ['wsgi.multiprocess'], ( "Inupy middleware is not usable in a " "multi-process environment") if self.inupy_config['ipfilter'] and not check_ipfilter(environ, self.inupy_config['ipfilter']): # then we want to filter on ip and this one failed return self.app(environ, start_response) else: req = Request(environ) req.base_path = req.application_url + '/_profiler' if req.path_info_peek() == '_profiler': return self.profiler(req)(environ, start_response) for regex in self.ignored_paths: if regex.match(environ['PATH_INFO']) is not None: return self.app(environ, start_response) return self.run_profile(environ, start_response)
def make_request(self, subpath='/', base_path='/_dozer'): req = Request(dict(PATH_INFO=subpath)) req.base_path = base_path return req
def make_request(self): req = Request({'PATH_INFO': '/whatevs', 'wsgi.url_scheme': 'http', 'HTTP_HOST': 'localhost'}) req.base_path = '/_dozer' return req