本文整理汇总了Python中pyramid.response.Response.content_location方法的典型用法代码示例。如果您正苦于以下问题:Python Response.content_location方法的具体用法?Python Response.content_location怎么用?Python Response.content_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.response.Response
的用法示例。
在下文中一共展示了Response.content_location方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: put_column
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import content_location [as 别名]
def put_column(self):
basename=self.request.matchdict['base']
path=self.request.matchdict['column'].split('/')
json_column=self.request.params['value']
str_async=self.request.params.get('async', 'false')
async=str_async.lower() == 'true'
if async:
# TODO: get user id! By John Doe
id_user=0
user_agent=self.request.user_agent
user_ip=self.request.client_addr
task_url=self.context.update_column_async(
path,
json_column,
id_user,
user_agent,
user_ip
)
result={
'task_url': task_url
}
response=Response(
status_code=202,
body=utils.object2json(result),
content_type='application/json'
)
response.content_location=task_url
# NOTE: Tentar fechar a conexão de qualquer forma!
# -> Na criação da conexão "coautocommit=True"!
# By Questor
try:
if self.context.session.is_active:
self.context.session.close()
except:
pass
return response
json_current_column=self.context.update_column(path, json_column)
# NOTE: Tentar fechar a conexão de qualquer forma!
# -> Na criação da conexão "coautocommit=True"!
# By Questor
try:
if self.context.session.is_active:
self.context.session.close()
except:
pass
return Response(json_current_column, content_type='application/json')