本文整理汇总了Python中privacyidea.lib.policy.PolicyClass.getPolicy方法的典型用法代码示例。如果您正苦于以下问题:Python PolicyClass.getPolicy方法的具体用法?Python PolicyClass.getPolicy怎么用?Python PolicyClass.getPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类privacyidea.lib.policy.PolicyClass
的用法示例。
在下文中一共展示了PolicyClass.getPolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SystemController
# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import getPolicy [as 别名]
#.........这里部分代码省略.........
except Exception as exx:
log.error("error saving policy: %r" % exx)
log.error(traceback.format_exc())
Session.rollback()
return sendError(response, exx)
finally:
Session.close()
########################################################
@log_with(log)
def policies_flexi(self, action, **params):
'''
This function is used to fill the policies tab
Unlike the complex /system/getPolcies function, it only returns a
simple array of the tokens.
'''
pol = {}
try:
param = getLowerParams(request.params)
name = getParam(param, "name", optional)
realm = getParam(param, "realm", optional)
scope = getParam(param, "scope", optional)
sortname = getParam(param, "sortname", optional)
sortorder = getParam(param, "sortorder", optional)
log.debug("retrieving policy name: %s, realm: %s, scope: %s, sort:%s by %s"
% (name, realm, scope, sortorder, sortname))
pols = self.Policy.getPolicy({'name':name, 'realm':realm, 'scope': scope}, display_inactive=True)
lines = []
for pol in pols:
lines.append(
{ 'id' : pol,
'cell': [
1 if pols[pol].get('active', "True") == "True" else 0,
pol,
pols[pol].get('user', ""),
pols[pol].get('scope', ""),
escape(pols[pol].get('action', "") or ""),
pols[pol].get('realm', ""),
pols[pol].get('client', ""),
pols[pol].get('time', "")
]
}
)
# sorting
reverse = False
sortnames = { 'active': 0, 'name' : 1, 'user' : 2, 'scope' : 3,
'action' : 4, 'realm' : 5, 'client':6, 'time' : 7 }
if sortorder == "desc":
reverse = True
lines = sorted(lines, key=lambda policy: policy['cell'][sortnames[sortname]] , reverse=reverse)
# end: sorting
# We need to return 'page', 'total', 'rows'
res = { "page": 1,
"total": len(lines),
"rows": lines }
c.audit['success'] = True