在web2py中,我试图将两个身份验证装饰器组合到一个方法中。
@auth.requires_permission('read', 'inv_header')
@auth.requires_permission('read', 'inv_detail')
我的理解是我这样做:
@auth.requires(auth.requires_permission('read', 'inv_header') and \
auth.requires_permission('read', 'inv_detail'))
但是我收到了这个错误。
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-stable + timestamp.2015.01.17.06.11.03 Python Python 2.7.5:/ usr / bin / python(前缀:/ usr)
我有什么遗失的东西吗?
我的环境如下:
web2py™ Version 2.9.12-stable+timestamp.2015.01.17.06.11.03
Python Python 2.7.5: /usr/bin/python (prefix: /usr)
答案 0 :(得分:1)
在@auth.requires
内,您必须使用auth.has_permission
,而不是auth.requires_permission
(后者是装饰者)。