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


Python Response.ubody方法代码示例

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


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

示例1: test_unicode_body

# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import ubody [as 别名]
def test_unicode_body():
    res = Response()
    res.charset = 'utf-8'
    bbody = 'La Pe\xc3\xb1a' # binary string
    ubody = unicode(bbody, 'utf-8') # unicode string
    res.body = bbody
    eq_(res.unicode_body, ubody)
    res.ubody = ubody
    eq_(res.body, bbody)
    del res.ubody
    eq_(res.body, '')
开发者ID:GdZ,项目名称:scriptfile,代码行数:13,代码来源:test_response.py

示例2: feed

# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import ubody [as 别名]
def feed(request, get_feed=get_feed):
    with shows_db() as shows:
        show_list = shows.values()

    d = PyQuery(get_feed(), parser="xml")

    for item in d("item"):
        ditem = PyQuery(item)
        title = ditem.find("title").text()
        match = detect_show(show_list, title)
        if match:
            name, episode = match
            # TODO: Record episode in the feed so that future versions of this episod will be ignored
        else:
            ditem.remove()

    response = Response()
    response.content_type = "application/rss+xml"
    response.ubody = unicode(d)
    response.cache_control = "no-cache"
    return response
开发者ID:ericmoritz,项目名称:tvservice,代码行数:23,代码来源:tvservice.py


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