【发布时间】:2017-09-13 17:21:51
【问题描述】:
我写了一个登录装饰器,它应该保证用户在执行另一个功能之前正确登录。问题是,尽管装饰器按预期工作,但函数包装的函数永远不会执行。我的结构如下:
#This is my decorator
login_required(func):
def func_wrapper(*args, **kwargs):
#do some operations
return True #or False
return func_wrapper
@login_required
def do_something(param1, param2, param3):
print("This print is not executing")
#continue the work that should be done after
#the user is authorized by the login decorator
我已经尝试移除装饰器中的返回 True/False,但它没有改变任何东西。
【问题讨论】:
标签: python decorator python-decorators