本文整理汇总了Python中privacyidea.lib.policy.PolicyClass.create_policy_export_file方法的典型用法代码示例。如果您正苦于以下问题:Python PolicyClass.create_policy_export_file方法的具体用法?Python PolicyClass.create_policy_export_file怎么用?Python PolicyClass.create_policy_export_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类privacyidea.lib.policy.PolicyClass
的用法示例。
在下文中一共展示了PolicyClass.create_policy_export_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SystemController
# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import create_policy_export_file [as 别名]
#.........这里部分代码省略.........
param = getLowerParams(request.params)
export = None
### config settings from here
try:
name = getParam(param, "name", optional)
realm = getParam(param, "realm", optional)
scope = getParam(param, "scope", optional)
display_inactive = getParam(param, "display_inactive", optional)
if display_inactive:
display_inactive = True
route_dict = request.environ.get('pylons.routes_dict')
export = route_dict.get('id')
log.debug("retrieving policy name: %s, realm: %s, scope: %s"
% (name, realm, scope))
pol = {}
if name != None:
for nam in name.split(','):
poli = self.Policy.getPolicy({'name':nam, 'realm':realm, 'scope': scope}, display_inactive=display_inactive)
pol.update(poli)
else:
pol = self.Policy.getPolicy({'name':name, 'realm':realm, 'scope': scope}, display_inactive=display_inactive)
c.audit['success'] = True
c.audit['info'] = "name = %s, realm = %s, scope = %s" \
% (name, realm, scope)
Session.commit()
if export:
filename = self.Policy.create_policy_export_file(pol, export)
wsgi_app = FileApp(filename)
return wsgi_app(request.environ, self.start_response)
else:
return sendResult(response, pol, 1)
except Exception as exx:
log.error("error getting policy: %r" % exx)
log.error(traceback.format_exc())
Session.rollback()
return sendError(response, exx)
finally:
Session.close()
########################################################
@log_with(log)
def delPolicy(self, action, **params):
"""
method:
system/delPolicy
description:
this function deletes the policy with the given name
arguments:
name - the policy with the given name
returns:
a json result about the delete success
exception:
if an error occurs an exception is serialized and returned