-
Notifications
You must be signed in to change notification settings - Fork 19
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
views: apply decorators once #41
Comments
@ppanero I think this is solved. We decorate in one place (the BaseView) with decorators that apply to all Resource methods and more spericifc method-related decorators can be added on each method separately. Did you have something else in mind? |
@fenekku The issue still applies, the main problem is that the decoration happens inside the However, if the function invokation is moved to the So it is half done:
|
Ok, then we should use the |
@fenekku when using that variable is the second point I was mentioning. Decorators are applied per class, and then not used in every function (get, post, etc). This would need some more research on the inner guts of flask/werkzeug I guess. |
I don't think I understand something here... With If the issue is about decorators only for some methods and not others, then that is already possible by putting a decorator on some methods and not others. In some cases, we could give extra support such as the 2nd option here: #59 . |
Theoretically what you say is right. However, when Alex and I tested it, this:
Did not work. That is why I say it requires more research. Maybe we did something wrong, or maybe it is not working as intended. |
Strange, 🤔 I will check it out this week. |
This is what is preventing us from using the built-in https://github.com/pallets/flask/blob/master/src/flask/app.py#L1852 return self.view_functions[rule.endpoint](**req.view_args) because |
The correct use case would be:
The current behaviour:
dispatch_request
.The ideal would be to decorate each method once, to avoid having the same chain of decorators in every module (e.g. content negotiation happens always, request loading also...)
EDIT
Goal of this issue is to refactor
BaseView
to usedecorators
to hold the common decorators. This will:as_view
is calledEDIT
As per comment below, we can't use
decorators
. The remaining issue is "decorating once". IMHO this is a nice to have, but not necessary now: the performance cost of this should be felt before. I suggest we delay this using my release management powers ⚡ 😉The text was updated successfully, but these errors were encountered: