ScopedRateThrottle support for function based views #9942
Replies: 1 comment
-
|
The shape you propose matches how the existing function-based view decorators work.
A focused change could be: def throttle_scope(scope):
def decorator(func):
_check_decorator_order(func, "throttle_scope")
func.throttle_scope = scope
return func
return decoratorand then in WrappedAPIView.throttle_scope = getattr(func, "throttle_scope", None)I cannot say whether maintainers will accept it, but it is small, follows the existing decorator pattern, and should be easy to test. I would include docs showing decorator order with |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently it's impossible to use
ScopedRateThrottlewith function based views. There was a workaround suggestion, but as the author stated it's rather nasty.It's possible to add
ScopedRateThrottlesupport for function based views by implementing the following changes:throttle_scopedecorator that would set athrottle_scopeattribute on the viewfunc, following the pattern of other decorators likethrottle_classes.api_view.decoratorfunction to copy the thethrottle_scopeattribute from the viewfuncto theWrappedAPIViewclass.Would the project maintainers accept such change? If so, I'll be glad to contribute it to the project.
Beta Was this translation helpful? Give feedback.
All reactions