New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert request params based on function annotations. #1441

Closed
coady opened this Issue Jun 5, 2016 · 0 comments

Comments

1 participant
@coady
Contributor

coady commented Jun 5, 2016

With the increasing focus on type hints in Python, having a tool which automatically converted query params (with exception handling) would be a nice feature.

It's common for apps to have boilerplate code for converting request params, and returning 400-levels errors on failure.

@cherrypy.tools.params(exception=ValueError)
def resource(self, limit: int):
    assert isinstance(limit, int) # a ValueError would have already raised a 400

coady added a commit to coady/cherrypy that referenced this issue Jun 5, 2016

coady added a commit to coady/cherrypy that referenced this issue Jun 5, 2016

coady added a commit to coady/cherrypy that referenced this issue Jun 7, 2016

@jaraco jaraco closed this in c060b46 Jul 19, 2016

jaraco added a commit that referenced this issue Jul 19, 2016

Merge pull request #1442 from coady/master
Convert request params based on function annotations.  Fixes #1441.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment