Flask-login Breaks When My Decorator Accepts Parameters
Thanks to what I learned from this question, I've been able to make a Flask-Login process with a endpoint like this: @app.route('/top_secret') @authorize @login_required def top_se
Solution 1:
Decorating a function is equivalent to re-binding the name to the result of calling the decorator with the function.
@authorizedeftop_secret():
...
# is equivalent todeftop_secret():
...
top_secret = authorize(top_secret)
The function you've written is a decorator factory: you call it, with an optional argument, to get a decorator.
@authorize()
deftop_secret():
...
# is equivalent todeftop_secret():
...
top_secret = authorize()(top_secret)
Currently, you're passing top_secret
as the group
argument to the factory, so you're never actually creating a route. Since there's no route, there's no url to build either.
Post a Comment for "Flask-login Breaks When My Decorator Accepts Parameters"