首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >结合web2py认证装饰器

结合web2py认证装饰器
EN

Stack Overflow用户
提问于 2015-04-21 06:54:14
回答 1查看 299关注 0票数 1

在web2py中,我试图将两个身份验证装饰器组合成一个方法。

代码语言:javascript
复制
@auth.requires_permission('read', 'inv_header')
@auth.requires_permission('read', 'inv_detail')

我的理解是我这样做:

代码语言:javascript
复制
@auth.requires(auth.requires_permission('read', 'inv_header') and \
auth.requires_permission('read', 'inv_detail'))

但我得到了这个错误。

代码语言:javascript
复制
Traceback (most recent call last):
  File "/opt/web-apps/web2py/gluon/restricted.py", line 224, in restricted
    exec ccode in environment
  File "/opt/web-apps/web2py/applications/niptview/controllers/batch.py", line 317, in <module>
  File "/opt/web-apps/web2py/gluon/globals.py", line 393, in <lambda>
    self._caller = lambda f: f()
  File "/opt/web-apps/web2py/gluon/tools.py", line 3437, in f
    flag = condition()
TypeError: decorator() takes exactly 1 argument (0 given)

Web2py版本2.9.12-稳定+时间戳.2015.01.17.06.11.03 PythonPython2.7.5: /usr/bin/python (前缀: /usr)

我遗漏了什么吗?

我的环境如下:

代码语言:javascript
复制
web2py™ Version 2.9.12-stable+timestamp.2015.01.17.06.11.03
Python  Python 2.7.5: /usr/bin/python (prefix: /usr)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-21 12:19:39

@auth.requires内部,您必须使用auth.has_permission,而不是auth.requires_permission (auth.requires_permission是一个装饰器)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29764971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档