本文整理汇总了Python中trac.perm.PermissionSystem.get方法的典型用法代码示例。如果您正苦于以下问题:Python PermissionSystem.get方法的具体用法?Python PermissionSystem.get怎么用?Python PermissionSystem.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.perm.PermissionSystem
的用法示例。
在下文中一共展示了PermissionSystem.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenhandler
# 需要导入模块: from trac.perm import PermissionSystem [as 别名]
# 或者: from trac.perm.PermissionSystem import get [as 别名]
def authenhandler(req):
pw = req.get_basic_auth_pw()
user = req.user
env = _get_env(req)
if env is None:
return apache.HTTP_FORBIDDEN
global acct_mgr
if acct_mgr is None:
from acct_mgr.api import AccountManager
acct_mgr = AccountManager
options = req.get_options()
#if 'TracPerm' not in options:
# req.log_error('mod_auth_acctmgr: You must specify a permission')
# return apache.HTTP_FORBIDDEN
perm = options.get('TracPerm')
if acct_mgr(env).check_password(user, pw):
if perm:
user_perms = PermissionSystem(env).get_user_permissions(user)
if not user_perms.get(perm):
return apache.HTTP_FORBIDDEN
return apache.OK
else:
return apache.HTTP_UNAUTHORIZED
示例2: perms
# 需要导入模块: from trac.perm import PermissionSystem [as 别名]
# 或者: from trac.perm.PermissionSystem import get [as 别名]
def perms(req):
user = req.user
env = _get_env(req)
if env is None:
return apache.HTTP_FORBIDDEN
options = req.get_options()
if 'TracPerm' not in options:
req.log_error('mod_auth_acctmgr: You must specify a permission')
return apache.HTTP_FORBIDDEN
perm = options['TracPerm']
user_perms = PermissionSystem(self.env).get_user_permissions(user)
if user_perms.get(perm):
return apache.OK
else:
return apache.HTTP_FORBIDDEN