WIP: Add Response.redirect shortcut
Call for comments :)
Should we:
- switch to function calls instead of setters (
json(xxx)
,redirect(xxx, permanent=True)
) - refrain from adding this kind of configurable shortcut
- keep it
This kind of shortcut setter may worth if for html()
, blob()
.
Using functions may be more powerful, but also more verbose, so keeping setters have the good point of constraining us in a simple API.
Benchmarks does not seem to show any difference between function call vs setter.
Also tried this shorter syntax, but this seems to have a notable effect of perfs (I guess because it acts as a proxy instead of replacing it at load time):
class setter:
def __init__(self, func):
self.func = func
self.__doc__ = func.__doc__
def __set__(self, obj, value):
return self.func(obj, value)
class Response:
@setter
def json(self, value):
xxxx