本文整理汇总了Python中cia.LibCIA.XML.htmlPrettyPrint方法的典型用法代码示例。如果您正苦于以下问题:Python XML.htmlPrettyPrint方法的具体用法?Python XML.htmlPrettyPrint怎么用?Python XML.htmlPrettyPrint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cia.LibCIA.XML
的用法示例。
在下文中一共展示了XML.htmlPrettyPrint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_message
# 需要导入模块: from cia.LibCIA import XML [as 别名]
# 或者: from cia.LibCIA.XML import htmlPrettyPrint [as 别名]
def render_message(self, context):
if not self.message:
context['request'].setResponseCode(404)
return self.notFoundMessage
# Try to format it using several media, in order of decreasing preference.
# The 'xhtml-long' formatter lets messages define a special formatter to
# use when an entire page is devoted to their one message, possibly showing
# it in greater detail. 'xhtml' is the formatter most messages should have.
# 'plaintext' is a nice fallback.
#
# This default list of media to try can be overridden with an argument in our URL.
if 'media' in context['args']:
mediaList = context['args']['media'][0].split()
else:
mediaList = ('xhtml-long', 'xhtml', 'plaintext')
for medium in mediaList:
try:
formatted = Formatters.getFactory().findMedium(
medium, self.message).formatMessage(self.message)
except Message.NoFormatterError:
continue
return formatted
# Still no luck? Display a warning message and a pretty-printed XML tree
return [
tag('h1')[ "No formatter available" ],
XML.htmlPrettyPrint(self.message.xml),
]