本文整理汇总了Python中pyramid.response.Response.unicode_body方法的典型用法代码示例。如果您正苦于以下问题:Python Response.unicode_body方法的具体用法?Python Response.unicode_body怎么用?Python Response.unicode_body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.response.Response
的用法示例。
在下文中一共展示了Response.unicode_body方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: elementListWidget
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import unicode_body [as 别名]
def elementListWidget(self, obj=None, elements=None, addResponse=True):
"""
Widget with existing elements list and edit options
call with obj = current object / page
"""
#i18n?
if not obj:
obj=self.context
html = u"""<div>
<h4 onclick="$.fn.editblocks().toggleBlock('#elements%(id)s',event)">%(title)s</h4>
%(blocks)s
</div>
"""
elHtml = u"""<div class="element">
<div class="el_title">%(title)s</div>
<div class="el_options">%(options)s</div>
<br style="clear:both"/>
</div>"""
if not elements:
elements = obj.GetPageElements()
localizer = translator(self.request)
blocks = StringIO()
static = self.StaticUrl("nive.cms.cmsview:static/images/types/")
for el in elements:
t = el.GetTitle()
if not t:
t = u"<em>%s</em>" % (localizer(el.GetTypeName(), self.request))
if el.GetTypeID()=="box":
title = u"<img src='%s%s.png' align='top'/> %s: %s" % (static, el.GetTypeID(), localizer(u"Box"), t)
blocks.write(elHtml % {u"title": title, u"options": self.editBlockList(obj=el, showCCP=True)})
for elb in el.GetPageElements():
t = elb.GetTitle()
if not t:
t = u"<em>%s</em>" % (localizer(elb.GetTypeName()))
title = u"> <img src='%s%s.png' align='top'/> %s" % (static, elb.GetTypeID(), t)
blocks.write(elHtml % {u"title": title, u"options": self.editBlockList(obj=elb, showCCP=True)})
else:
title = u"<img src='%s%s.png' align='top'/> %s" % (static, el.GetTypeID(), t)
blocks.write(elHtml % {u"title": title, u"options": self.editBlockList(obj=el, showCCP=True)})
if not len(elements):
blocks.write(localizer(_(u"<p><i>empty</i></p>")))
data = html % {u"blocks": blocks.getvalue(), u"id": str(obj.GetID()), u"title": localizer(_(u"Page elements"))}
if addResponse:
r = Response(content_type="text/html", conditional_response=True)
r.unicode_body = data
return r
return data
示例2: editBlockElement
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import unicode_body [as 别名]
def editBlockElement(self, obj=None, addResponse=True):
"""
Edit bar for elements
if obj is None current context is used
"""
if not obj:
obj=self.context
data = render("widgets/editblock_element.pt", {u"obj":obj, u"view":self}, request=self.request)
if addResponse:
r = Response(content_type="text/html", conditional_response=True)
r.unicode_body = data
return r
return data
示例3: sitemap_view
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import unicode_body [as 别名]
def sitemap_view(context, request):
portal = request.context
# portal google sitemap link
r = Response(content_type="text/xml", conditional_response=False)
r.unicode_body = portal.configuration.sitemap
return r
示例4: robots_view
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import unicode_body [as 别名]
def robots_view(context, request):
portal = request.context
# website root / domain root redirect
r = Response(content_type="text/plain", conditional_response=False)
r.unicode_body = portal.configuration.robots
return r