def __call__(self, *args, **kwargs): try: self.update(*args, **kwargs) self.updateForm() result = self.render(*args, **kwargs) return self.make_response(result, *args, **kwargs) except HTTPRedirect, exc: return redirect_exception_response(self.responseFactory, exc)
def test_redirect_exceptions(): redirections = browser.exceptions.REDIRECTIONS.items() for code, exception in redirections: assert code == exception.code exc = exception('some location') assert exc.location == 'some location' response = browser.redirect_exception_response( testing.TestResponse, exc) assert response.status == "%s %s" % (code, exc.title) assert response.headers['Location'] == 'some location' assert response.headers['Content-Length'] == '0' assert response.headers['Content-Type'] == 'text/plain'
def make_exception_response(): return redirect_exception_response(Response, exception)
def exception_response(request, exception): return redirect_exception_response(Response, exception)