开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜