How to group decorators in Python

不羁的心 提交于 2019-12-05 11:13:24
Edward Minnix

You're not defining the composition correctly. You need to change the definition of nice_decorator to something like this:

def nice_decorator(route):
    return composed(
        app.route(route),
        auth.login_required,
        crossdomain(origin="*"),
        nocache
    )

Your previous version never actually returned anything. Python isn't like Ruby or Lisp where the last expression is the return value.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!