inveniosoftware / inveniosoftware/flask-resources

views: apply decorators once

Open
#41 8 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
3
Forks
22
PR merge metrics
No merged PRs in 30d

Description

The correct use case would be:

- The method/view gets decorated once
- The decorator is called each time the function is invoked

The current behaviour:

- The method/view is decorated each time a function (get, post, etc.) is invoked. This happens because it is being decorated in the `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 use `decorators` to hold the common decorators. This will:
- decorate in one place the common decorators
- decorate once when `as_view` is called

**EDIT**
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 :zap: :wink:

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.