Closed manthey closed 8 years ago
I'd like to avoid exposing CherryPy through the Tangelo API.
Currently, you can "exit early" for errors and not found by saying tangelo.http_status(404)
etc. followed by a return
statement (which, if there is nothing to signal to the client, can simply be e.g. return None
).
That leaves redirects. Would it be ok to create special functions like tangelo.internal_redirect()
and tangelo.redirect()
that could be used similarly to signal these cases? You would say return tangelo.redirect("/other/url")
and the server infrastructure would turn it into the appropriate CherryPy logic.
@manthey let me know what you think.
I think having tangelo.redirect()
and tangelo.internal_redirect
are good way to do this.
In
invoke_service
, some exceptions should not be caught by the handler (currently on line 462). For instance,cherrypy.HTTPRedirect
should be allowed to be raised so that when a return value with a Last-Modified header hasn't changed, the data need not be transferred to the caller.Rather than
except:
, I'd recommendThere are other cherrypy exceptions that perhaps should also be raised. Candidates are
cherrypy.HTTPError
, which would allow services to just raise an explicit error to exit early,cherrypy.InternalRedirect
, which might be usable to redirect to another endpoint, andcherrypy.NotFound
, which would allow a service to return an explicit 404 to exit early.