当前位置: 首页>>代码示例>>Python>>正文


Python Response.content_range方法代码示例

本文整理汇总了Python中webob.Response.content_range方法的典型用法代码示例。如果您正苦于以下问题:Python Response.content_range方法的具体用法?Python Response.content_range怎么用?Python Response.content_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webob.Response的用法示例。


在下文中一共展示了Response.content_range方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_shots_children_task_type

# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import content_range [as 别名]
def get_shots_children_task_type(request):
    """returns the Task Types defined under the Shot container
    """

    sql_query = """select
        "SimpleEntities".id as type_id,
        "SimpleEntities".name as type_name
    from "SimpleEntities"
    join "SimpleEntities" as "Task_SimpleEntities" on "SimpleEntities".id = "Task_SimpleEntities".type_id
    join "Tasks" on "Task_SimpleEntities".id = "Tasks".id
    join "Shots" on "Tasks".parent_id = "Shots".id
    group by "SimpleEntities".id, "SimpleEntities".name
    order by "SimpleEntities".name"""

    result = DBSession.connection().execute(sql_query)

    return_data = [{"id": r[0], "name": r[1]} for r in result.fetchall()]

    content_range = "%s-%s/%s"

    type_count = len(return_data)
    content_range = content_range % (0, type_count - 1, type_count)

    logger.debug("content_range : %s" % content_range)

    resp = Response(json_body=return_data)
    resp.content_range = content_range
    return resp
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:30,代码来源:shot.py

示例2: get_assets_type_task_types

# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import content_range [as 别名]
def get_assets_type_task_types(request):
    """returns the Task Types defined under the Asset container
    """

    type_id = request.matchdict.get('t_id', None)

    logger.debug('type_id %s'% type_id)


    sql_query = """select
        "SimpleEntities".id as type_id,
        "SimpleEntities".name as type_name
    from "SimpleEntities"
    join "SimpleEntities" as "Task_SimpleEntities" on "SimpleEntities".id = "Task_SimpleEntities".type_id
    join "Tasks" on "Task_SimpleEntities".id = "Tasks".id
    join "Assets" on "Tasks".parent_id = "Assets".id
    join "SimpleEntities" as "Assets_SimpleEntities" on "Assets_SimpleEntities".id = "Assets".id

    %(where_condition)s

    group by "SimpleEntities".id, "SimpleEntities".name
    order by "SimpleEntities".name"""


    where_condition = ''

    if type_id:
        where_condition = 'where "Assets_SimpleEntities".type_id = %(type_id)s'%{'type_id': type_id}

    sql_query = sql_query %{'where_condition':where_condition}



    result = DBSession.connection().execute(sql_query)

    return_data = [
        {
            'id': r[0],
            'name': r[1]

        }
        for r in result.fetchall()
    ]

    content_range = '%s-%s/%s'

    type_count = len(return_data)
    content_range = content_range % (0, type_count - 1, type_count)

    logger.debug('content_range : %s' % content_range)

    resp = Response(
        json_body=return_data
    )
    resp.content_range = content_range
    return resp
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:58,代码来源:asset.py

示例3: make_response

# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import content_range [as 别名]
def make_response(uri, environ):
    
    res = Response(conditional_response=True)
    
    # check if the host is online. If not raise an http error
    if not pingSMB( parseSMBuri(uri)["host"] ):
        return HTTPGatewayTimeout("Host is currently offline. You may try again at a later time.")
    
    try:
        f = c.open(uri)
    except smbc.NoEntryError:
        return HTTPNotFound("The file you requested is no longer available!")
    
    fs = f.fstat()
    filesize = fs[6]
    last_modified = fs[8] # mtime
    filename = uri.split("/")[-1]
    req = Request(environ)
    log.debug("Incoming request: \n" + str(req))
    
    if req.range:
        log.debug("begin ranged transfer")
        res.status_int = 206
        res.content_range = req.range.content_range(filesize)
        (start, stop) = req.range.range_for_length(filesize)
        
        log.debug("filesize: " + str(filesize))
        log.debug("start: " + str(start)  + "   stop: " + str(stop))
        log.debug("Content-Range: " + str(res.content_range))
        
        res.app_iter = FileIterable(uri, start=start, stop=stop)
        res.content_length = stop - start
    
    else:
        log.debug("begin normal transfer")
        res.app_iter = FileIterable(uri)
        res.content_length = filesize
    
    log.debug("Content-Length: " + str(res.content_length))
    
    res.server_protocol = "HTTP/1.1"
    # Make sure the file gets downloaded and not played live
    res.content_type = "application/octet-stream"
    res.last_modified = last_modified
    res.etag = '%s-%s-%s' % (fs[8], fs[6], hash(f))
    res.headers.add("Content-Disposition", 'attachment; filename="%s"' % str(filename) )
    res.headers.add("Accept-Ranges", "bytes")
    return res
开发者ID:agrynchuk,项目名称:noodle-ng,代码行数:50,代码来源:smbfileapp.py

示例4: get_assets_types

# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import content_range [as 别名]
def get_assets_types(request):
    """returns the Asset Types
    """


    sql_query ="""select
     "Assets_Types_SimpleEntities".id,
     "Assets_Types_SimpleEntities".name

     from "Assets"

     join "SimpleEntities" as "Assets_SimpleEntities" on "Assets_SimpleEntities".id = "Assets".id
     join "SimpleEntities" as "Assets_Types_SimpleEntities" on "Assets_Types_SimpleEntities".id = "Assets_SimpleEntities".type_id

     group by
        "Assets_Types_SimpleEntities".name,
        "Assets_Types_SimpleEntities".id
     order by "Assets_Types_SimpleEntities".name
     """


    result = DBSession.connection().execute(sql_query)

    return_data = [
        {
            'asset_type_id': r[0],
            'asset_type_name': r[1]

        }
        for r in result.fetchall()
    ]

    content_range = '%s-%s/%s'

    type_count = len(return_data)
    content_range = content_range % (0, type_count - 1, type_count)

    logger.debug('content_range : %s' % content_range)

    resp = Response(
        json_body=return_data
    )
    resp.content_range = content_range
    return resp
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:46,代码来源:asset.py

示例5: get_shots

# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import content_range [as 别名]
def get_shots(request):
    """returns all the Shots of the given Project
    """
    entity_id = request.matchdict.get("id", -1)
    entity = Entity.query.filter_by(id=entity_id).first()

    shot_id = request.params.get("entity_id", None)

    logger.debug("get_shots function starts : ")

    sql_query = """select
    "Shots".id as shot_id,
    "Shot_SimpleEntities".name as shot_name,
    "Shot_SimpleEntities".description as shot_description,
    "Links".full_path as shot_full_path,
    "Distinct_Shot_Statuses".shot_status_code as shot_status_code,
    "Distinct_Shot_Statuses".shot_status_html_class as shot_status_html_class,
    array_agg("Distinct_Shot_Task_Types".type_name) as type_name,
    array_agg("Tasks".id) as task_id,
    array_agg("Task_SimpleEntities".name) as task_name,
    array_agg("Task_Statuses".code) as status_code,
    array_agg("Task_Statuses_SimpleEntities".html_class) as status_html_class,
    array_agg(coalesce(
            -- for parent tasks
            (case "Tasks".schedule_seconds
                when 0 then 0
                else "Tasks".total_logged_seconds::float / "Tasks".schedule_seconds * 100
             end
            ),
            -- for child tasks we need to count the total seconds of related TimeLogs
            (coalesce("Task_TimeLogs".duration, 0.0))::float /
                ("Tasks".schedule_timing * (case "Tasks".schedule_unit
                    when 'min' then 60
                    when 'h' then 3600
                    when 'd' then 32400
                    when 'w' then 147600
                    when 'm' then 590400
                    when 'y' then 7696277
                    else 0
                end)) * 100.0
        )) as percent_complete,
    "Shot_Sequences".sequence_id as sequence_id,
    "Shot_Sequences_SimpleEntities".name as sequence_name
from "Tasks"
join "Shots" on "Shots".id = "Tasks".parent_id
join "SimpleEntities" as "Shot_SimpleEntities" on "Shots".id = "Shot_SimpleEntities".id
join "SimpleEntities" as "Task_SimpleEntities" on "Tasks".id = "Task_SimpleEntities".id
left join "Links" on "Shot_SimpleEntities".thumbnail_id = "Links".id
join(
    select
        "Shots".id as shot_id,
        "Statuses".code as shot_status_code,
        "SimpleEntities".html_class as shot_status_html_class
    from "Tasks"
    join "Shots" on "Shots".id = "Tasks".id
    join "Statuses" on "Statuses".id = "Tasks".status_id
    join "SimpleEntities" on "SimpleEntities".id = "Statuses".id
    )as "Distinct_Shot_Statuses" on "Shots".id = "Distinct_Shot_Statuses".shot_id
left join (
    select
        "SimpleEntities".id as type_id,
        "SimpleEntities".name as type_name
    from "SimpleEntities"
    join "SimpleEntities" as "Task_SimpleEntities" on "SimpleEntities".id = "Task_SimpleEntities".type_id
    join "Tasks" on "Task_SimpleEntities".id = "Tasks".id
    join "Shots" on "Tasks".parent_id = "Shots".id
    group by "SimpleEntities".id, "SimpleEntities".name
    order by "SimpleEntities".id
) as "Distinct_Shot_Task_Types" on "Task_SimpleEntities".type_id = "Distinct_Shot_Task_Types".type_id
join "Statuses" as "Task_Statuses" on "Tasks".status_id = "Task_Statuses".id
join "SimpleEntities" as "Task_Statuses_SimpleEntities" on "Task_Statuses_SimpleEntities".id = "Tasks".status_id
left join "Shot_Sequences" on "Shot_Sequences".shot_id = "Shots".id
left join "SimpleEntities" as "Shot_Sequences_SimpleEntities" on "Shot_Sequences_SimpleEntities".id = "Shot_Sequences".sequence_id
left outer join (
            select
                "TimeLogs".task_id,
                extract(epoch from sum("TimeLogs".end::timestamp AT TIME ZONE 'UTC' - "TimeLogs".start::timestamp AT TIME ZONE 'UTC')) as duration
            from "TimeLogs"
            group by task_id
        ) as "Task_TimeLogs" on "Task_TimeLogs".task_id = "Tasks".id
%(where_condition)s
group by
    "Shots".id,
    "Shot_SimpleEntities".name,
    "Shot_SimpleEntities".description,
    "Links".full_path,
    "Distinct_Shot_Statuses".shot_status_code,
    "Distinct_Shot_Statuses".shot_status_html_class,
    "Shot_Sequences".sequence_id,
    "Shot_Sequences_SimpleEntities".name
order by "Shot_SimpleEntities".name
"""

    # set the content range to prevent JSONRest Store to query the data twice
    content_range = "%s-%s/%s"
    where_condition = ""

    if entity.entity_type == "Sequence":
        where_condition = 'where "Shot_Sequences".sequence_id = %s' % entity_id

#.........这里部分代码省略.........
开发者ID:Dr-Rakcha,项目名称:stalker-pyramid,代码行数:103,代码来源:shot.py


注:本文中的webob.Response.content_range方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。