【发布时间】:2020-01-15 16:56:58
【问题描述】:
我正在尝试包装为烧瓶 (Flask-Kerberos) 制作的身份验证装饰器。我需要将参数传递给包装器,但我似乎不知道该怎么做。
原始工作代码:
#main.py:
@app.route("/")
@requires_authentication
def index(user):
return render_template('index.html', user=user)
代码无效,但说明了我正在尝试做的事情:
#main.py
from auth import customauth
@app.route("/")
@customauth(config)
def index(user):
return render_template('index.html', user=user)
#auth.py
def customauth(*args, **kwargs):
@requires_authentication
def inner(func):
print(config)
return func
return inner
【问题讨论】:
标签: python flask python-decorators