Ability to add decorators to the serve method
See original GitHub issueAt the moment, there is no way to add decorators to the serve
method.
For example, we can’t add the csrf_exempt
decorator. It may be useful for form pages with captcha (because there is no need in csrf token).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to Create and Use Decorators in Python With Examples
In this article I will show you how to create and use decorators. You will see how easy it is to use this...
Read more >Documentation - Decorators - TypeScript
Decorators provide a way to add both annotations and a meta-programming syntax for class declarations and members. Decorators are a stage 2 proposal...
Read more >Decorators and forwarding, call/apply
Decorators can be seen as “features” or “aspects” that can be added to a function. We can add one or add many. And...
Read more >Modify a method using TypeScript decorators | Create & Code
We want to use the decorator for multiple service methods, so we need to be able to specify a unique cache key each...
Read more >Attaching new behaviors through decorators in JavaScript
Decorator is a function that gives the ability to dynamically modify the existing functionality: by higher-order functions in the functional ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @thenewguy! This looks good to me - a simple, backwards-compatible change that will allow people to solve this problem, and it doesn’t preclude building a more out-of-the-box solution in future that respects the CSRF flag without the need for a custom middleware, if there’s a desire for that.
So, in terms of the change to be made to Wagtail itself, this would just involve building, documenting and testing the find_page_for_request helper - nothing about that needs to indicate that it’s intended for use in middleware / CSRF handling. (If you were to subsequently write up a recipe detailing how to use this for CSRF control, I’d sure that would be welcomed, but probably out of scope for the main Wagtail docs and a better fit for a blog post or similar.) For the tests, we’d just need to validate that
find_page_for_request
returns the right result and thatassertNumQueries
gives 0 for any calls after the initial one.@zerolab @gasman This is the issue/solution I was referring to. Do you like it?