Pylons / pyramid

Pyramid - A Python web framework
https://trypyramid.com/
Other
3.97k stars 887 forks source link

How to get permission name that causes forbidden error? #3692

Closed dabajabaza closed 2 years ago

dabajabaza commented 2 years ago

I want to know permission name that causes forbidden error, get it in forbidden view and return to user. How to do it?

Pyramid version 1.10.4

...

# if user does not have PERMISSIONS.name this causes forbidden error
config.add_view(
    SomeView,
    attr="some_class_attribute",
    permission=PERMISSIONS.name,
    renderer="json",
    request_method="GET",
    route_name=route_name,
)

... 

@forbidden_view_config(renderer="json")
def forbidden(request):
    permission_name = get_permission_name(request)
    return permission_name
stevepiercy commented 2 years ago

https://pylonsproject.org/community-support.html

GitHub is the least desirable option. Posting a request for general support to the project's GitHub issue tracker reaches the smallest audience, and takes time away from fixing bugs and adding features. Please don't be "that person".

dabajabaza commented 2 years ago

@stevepiercy thank you for your advice and sorry for my mistake.