如何传输 url 参数以重新配置自定义谓词检查器
我想创建一个 repoze 自定义谓词检查器,它能够访问 url 参数并验证某些内容。但我想使用allow_only 在所有控制器的范围内设置此权限检查器。类似于:
class MyController(BaseController):
allow_only = All(not_anonymous(msg=l_(u'You must be logged on')),
my_custom_predicate(msg=l_(u'something wrong')))
def index(self, **kw):
return dict()
然后,my_custom_predicate 应该检查每个 MyController 方法中每个请求的 url 参数,并执行它所做的任何操作。 问题在于:如何允许 my_custom_predicate 检查 url 参数,以我上面写的方式使用它。
I would like to create a repoze custom predicate checker that is capable to access url parameters and validate something. But I would like to use allow_only to set this permission checker in all the controller's scope. Something like:
class MyController(BaseController):
allow_only = All(not_anonymous(msg=l_(u'You must be logged on')),
my_custom_predicate(msg=l_(u'something wrong')))
def index(self, **kw):
return dict()
then, my_custom_predicate should check the url paramters for every request in every MyController method, and do whatever it do.
The problem is just that: how to allow my_custom_predicate to check the url parameters, using it in that way I wrote above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能您需要使用 ControllerProtector
请参阅 http 上的文档://code.gustavonarea.net/repoze.what-pylons/API.html
May be you need to use ControllerProtector
See docs at http://code.gustavonarea.net/repoze.what-pylons/API.html