def download_script(request):
"""
Download script file or archive.
READ permission required on script.
---
script_id:
type: string
required: true
in: path
"""
script_id = request.matchdict['script_id']
auth_context = auth_context_from_request(request)
if not script_id:
raise RequiredParameterMissingError('No script id provided')
try:
script = Script.objects.get(owner=auth_context.owner,
id=script_id, deleted=None)
except me.DoesNotExist:
raise NotFoundError('Script id not found')
# SEC require READ permission on SCRIPT
auth_context.check_perm('script', 'read', script_id)
try:
return script.ctl.get_file()
except BadRequestError():
return Response("Unable to find: {}".format(request.path_info))
# SEC
评论列表
文章目录