问题
I add a view for the forbidden view:
from pyramid.exceptions import Forbidden
config.add_view(forbidden_view, context=Forbidden)
which redirects to a log in screen.
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?
回答1:
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.
来源:https://stackoverflow.com/questions/4916149/how-to-check-what-permission-failed-in-authorization-in-pyramid-pylons-2