本文整理汇总了Python中pyramid.response.Response.content_range方法的典型用法代码示例。如果您正苦于以下问题:Python Response.content_range方法的具体用法?Python Response.content_range怎么用?Python Response.content_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.response.Response
的用法示例。
在下文中一共展示了Response.content_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_resources
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import content_range [as 别名]
#.........这里部分代码省略.........
) and project_id = %s
group by id, start, "end", "Tasks".computed_start, "Tasks".computed_end
order by start
"""
has_children = True
else:
# return departments ??? should also return Groups, Project etc.
# that contains users
resource_sql_query = """select
"Users".id,
"SimpleEntities".name,
"SimpleEntities".entity_type,
1 as resource_count
from "Users"
join "SimpleEntities" on "SimpleEntities".id = "Users".id
join "User_Departments" on "User_Departments".uid = "Users".id
join "Departments" on "User_Departments".did = "Departments".id
where "Departments".id = %s
order by name
""" % parent_id
time_log_query = """select
"TimeLogs".id,
"TimeLogs".task_id,
extract(epoch from "TimeLogs".start::timestamp AT TIME ZONE 'UTC') * 1000 as start,
extract(epoch from "TimeLogs".end::timestamp AT TIME ZONE 'UTC') * 1000 as end
from "TimeLogs"
where resource_id = %s
"""
tasks_query = """select
"Tasks".id,
extract(epoch from "Tasks".computed_start::timestamp AT TIME ZONE 'UTC') * 1000 as start,
extract(epoch from "Tasks".computed_end::timestamp AT TIME ZONE 'UTC') * 1000 as end
from "Tasks"
join "Task_Resources" on "Tasks".id = "Task_Resources".task_id
where
not (
exists (
select 1
from (
select "Tasks".parent_id
from "SimpleEntities"
join "Tasks" on "SimpleEntities".id = "Tasks".id
) AS all_tasks
where all_tasks.parent_id = "Tasks".id
)
) and resource_id = %s
"""
has_children = False
logger.debug('resource_sql_query : %s' % resource_sql_query)
logger.debug('time_log_query : %s' % time_log_query)
logger.debug('tasks_sql_query : %s' % tasks_query)
resources_result = execute(resource_sql_query).fetchall()
logger.debug('resources_result : %s' % resources_result)
link = '/%s/%s/view' % (entity_type.lower(), '%s')
data = [
{
'id': rr[0],
'name': rr[1],
'type': rr[2],
'resource_count': rr[3],
'hasChildren': has_children,
'link': link % rr[0],
'time_logs': [
{
'id': tr[0],
'task_id': tr[1],
'start': tr[2],
'end': tr[3]
} for tr in execute(time_log_query % rr[0]).fetchall()
],
'tasks': [
{
'id': tr[0],
'start': tr[1],
'end': tr[2]
} for tr in execute(tasks_query % rr[0]).fetchall()
]
} for rr in resources_result
]
end = time.time()
logger.debug('get_resources took : %s seconds' % (end - start))
data_count = len(data)
content_range = '%s-%s/%s' % (0, data_count - 1, data_count)
resp = Response(
json_body=data
)
resp.content_range = content_range
return resp