开发者

Check if a user has a permission in pyramid (pylons 2)?

开发者 https://www.devze.com 2023-02-08 17:29 出处:网络
How do i check if a user has a permission in pyramid.For example, I w开发者_运维百科ant to show some HTML only if a user has some permission, but have the view available for everybody.The usual method

How do i check if a user has a permission in pyramid. For example, I w开发者_运维百科ant to show some HTML only if a user has some permission, but have the view available for everybody.


The usual method is:

from pyramid.security import has_permission
has_permission('view', someresource, request)

See also http://docs.pylonsproject.org/projects/pyramid/1.0/narr/security.html#debugging-imperative-authorization-failures and http://docs.pylonsproject.org/projects/pyramid/1.0/api/security.html#pyramid.security.has_permission

0

精彩评论

暂无评论...
验证码 换一张
取 消