本文整理汇总了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, '')
示例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