如何检查金字塔(pylons 2)中授权失败的权限? [英] How to check what permission failed in authorization in pyramid (pylons 2)?

查看:53
本文介绍了如何检查金字塔(pylons 2)中授权失败的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为禁止视图添加了一个视图:

I add a view for the forbidden view:

from pyramid.exceptions import Forbidden
config.add_view(forbidden_view, context=Forbidden)

重定向到登录屏幕.

但现在我添加了一些需要管理员访问权限的管理内容,我只想显示您没有权限"屏幕,我如何在禁止视图中检查?

But now i added some admin things which needed admin access, and I want to just show a "you don't have the permission" screen, how do I check for that in the forbidden view?

推荐答案

当 Pyramid 由于权限被拒绝而引发 Forbidden 错误时,我担心信息会丢失.TODO.txt 中有一个项目可以通过 Forbidden 错误携带它.

I'm afraid that information is lost when Pyramid raises a Forbidden error as the result of a permission denial. There's an item in the TODO.txt to carry it along through the Forbidden error.

这篇关于如何检查金字塔(pylons 2)中授权失败的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆