def __call__(self, environ, start_response): """Minimal WSGI application for request dispatching.""" #: bind the application to the new context local self.bind_to_context() request = Request(environ) request.bind_to_context() urls = urlmap.bind_to_environ(environ) try: endpoint, args = urls.match(request.path) handler = get_controller(endpoint) resp = handler(**args) except NotFound: handler = get_controller('static/not_found') resp = handler() except HTTPException, e: resp = e.get_response(environ)
def __call__(self, environ, start_response): """Minimal WSGI application for request dispatching.""" #: bind the application to the new context local self.bind_to_context() request = Request(environ) request.bind_to_context() ctx.url_adapter = urls = urlmap.bind_to_environ(environ) try: endpoint, args = urls.match(request.path) handler = get_controller(endpoint) resp = handler(**args) except NotFound: handler = get_controller('static/not_found') resp = handler() except HTTPException, e: resp = e.get_response(environ)
def __call__(self, environ, start_response): """Minimal WSGI application for request dispatching.""" #: bind the application to the new context local self.bind_to_context() request = Request(environ) request.bind_to_context() ctx.url_adapter = urls = urlmap.bind_to_environ(environ) try: endpoint, args = urls.match(request.path) handler = get_controller(endpoint) resp = handler(**args) except NotFound: handler = get_controller('static/not_found') resp = handler() except HTTPException as e: resp = e.get_response(environ) else: expires = datetime.utcnow() + timedelta(days=31) if request.first_visit or request.session.should_save: request.session.save_cookie(resp, COOKIE_NAME, expires=expires) return ClosingIterator(resp(environ, start_response), self.cleanup_callbacks)