Skip to content

Added make_response to FlaskView as a class method#60

Open
ryanolson wants to merge 1 commit into
apiguy:masterfrom
ryanolson:make_response
Open

Added make_response to FlaskView as a class method#60
ryanolson wants to merge 1 commit into
apiguy:masterfrom
ryanolson:make_response

Conversation

@ryanolson
Copy link
Copy Markdown

I've added the ability to override Flask's make_response function by adding a new make_response class method to FlaskView.

The motivation is to provide an final and inheritable "decorator-like" function that wraps the view's response.

Decorators are inheritable; however, if a subclass wishes to modify the decorator list, they need to be aware of the parents decorators to do so.

I'm not sure if this function should be an instance function or a class method. I've created it as a class method; however, I'd be willing to change it to an instance method to provide easier and cleaner subclassing.

My personal motivation for this pull request is to replace Flask-RESTful's MethodView with FlaskView.

I like the design where the API views return the data directly and the make_response provides the final conversion to the output representation requested.

@EvaSDK
Copy link
Copy Markdown

EvaSDK commented Jul 23, 2014

Maybe you can handle that in a serialization middleware.
I use Flask RESTful MethodView as well, not only for this though and I haven't decided yet which is best behavior.

@ryanolson
Copy link
Copy Markdown
Author

@apiguy - thoughts?

@dwcaraway
Copy link
Copy Markdown

FWIW I like @ryanolson 's fix of allowing the View to override the make_response method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants