本文整理汇总了Python中nevow.tags.xml函数的典型用法代码示例。如果您正苦于以下问题:Python xml函数的具体用法?Python xml怎么用?Python xml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render_publicationDiv
def render_publicationDiv(self, context, data):
if self.query.order == 'publication_time':
return tags.xml('<span class="selectedCriterium">'
'publication time</span>')
else:
return tags.xml("""<span class="unselectedCriterium"><a href="javascript: sortBy('publication_time');">"""
'publication time</a></span>')
示例2: render_popularityDiv
def render_popularityDiv(self, context, data):
if self.query.order == 'popularity':
return tags.xml('<span class="selectedCriterium">'
'popularity</span>')
else:
return tags.xml("""<span class="unselectedCriterium"><a href="javascript: sortBy('popularity');">"""
'popularity</a></span>')
示例3: render_relevanceDiv
def render_relevanceDiv(self, context, data):
if self.query.order == 'relevance':
return tags.xml('<span class="selectedCriterium">'
'relevance</span>')
else:
return tags.xml("""<span class="unselectedCriterium"><a href="javascript: sortBy('relevance');">"""
'relevance</a></span>')
示例4: test_xml
def test_xml(self):
"""
An L{xml} instance is flattened to the UTF-8 representation of itself.
"""
self.assertStringEqual(self.flatten(xml("foo")), "foo")
unich = u"\N{LATIN CAPITAL LETTER E WITH GRAVE}"
self.assertStringEqual(self.flatten(xml(unich)), unich.encode('utf-8'))
示例5: cruftifyMultipleSpaces
def cruftifyMultipleSpaces(text):
"""Replace multiple spaces with such that they are rendered as we want."""
if text.startswith(' '):
yield tags.xml(' ')
text = text[1:]
chunks = text.split(' ')
for i in SpacePreservingStringRenderer.intersperse(tags.xml('  '), chunks):
yield i
示例6: inlineJSSerializer
def inlineJSSerializer(original, ctx):
from nevow import livepage
from nevow.tags import script, xml
theJS = livepage.js(original.children)
new = livepage.JavascriptContext(ctx, invisible[theJS])
return serialize(script(type="text/javascript")[
xml('\n//<![CDATA[\n'),
serialize(theJS, new),
xml('\n//]]>\n')], ctx)
示例7: head
def head(self, request, website):
def styleSheetLink(href):
return tags.link(rel='stylesheet', type='text/css', href=href)
root = website.cleartextRoot(request.getHeader('host'))
styles = root.child('Eridanus').child('static').child('styles')
yield styleSheetLink(styles.child('eridanus.css'))
yield tags.xml(u'<!--[if IE 6]>'), styleSheetLink(styles.child('eridanus-ie6.css')), tags.xml(u'<![endif]-->')
yield tags.xml(u'<!--[if IE 7]>'), styleSheetLink(styles.child('eridanus-ie7.css')), tags.xml(u'<![endif]-->')
示例8: render_next
def render_next(self, context, data):
"""computes 'Next' link"""
localCount, distantCount = self.querier.countResults(self.qid)
if self.onlyDistant:
resultsCount = distantCount
elif self.onlyLocal:
resultsCount = localCount
else:
resultsCount = localCount + distantCount
offset = self.query.offset
if (offset + 15) < resultsCount:
return tags.xml('<a href="javascript: browseResults(%s);">Next</a>' % (offset + 15))
return tags.xml('<span class="selectedCriterium">Next</span>')
示例9: head
def head(self, request, website):
def styleSheetLink(href):
return tags.link(rel='stylesheet', type='text/css', href=href)
root = website.rootURL(request)
styles = root.child('static').child('Methanal').child('styles')
yield styleSheetLink(styles.child('methanal.css'))
yield (tags.xml(u'<!--[if IE 6]>'),
styleSheetLink(styles.child('methanal-ie6.css')),
tags.xml(u'<![endif]-->'))
yield (tags.xml(u'<!--[if IE 7]>'),
styleSheetLink(styles.child('methanal-ie7.css')),
tags.xml(u'<![endif]-->'))
示例10: render_item_template_js
def render_item_template_js(self, ctx, data):
html = T.script(type="text/javascript", language="javascript" )
js = """function getTemplates(plugin) {
%(pluginTemplates)s
}
"""
fragment = """ if(plugin == "%(plugin)s") {
return new Array(%(templates)s);
}
"""
fragments = []
for plugin in self._typesList(ctx):
templates = ','.join( ['["%s","%s"]'%(t[0],t[1]) for t in plugin.listTemplates])
fragments.append(fragment%{'plugin':plugin.contentItemClass.__typename__,
'templates':templates})
fragments.append( """ { return new Array(); } """)
pluginTemplates = ' else '.join(fragments)
js = js%{'pluginTemplates': pluginTemplates}
return html[T.xml(js)]
示例11: render_basket_item
def render_basket_item(self, ctx, basketItem):
ctx.tag.fillSlots('code', basketItem.code or '')
ctx.tag.fillSlots('description', T.xml(basketItem.description) or '')
ctx.tag.fillSlots('quantity_ordered', basketItem.quantity_ordered)
ctx.tag.fillSlots('unit_price', basketItem.unit_price)
ctx.tag.fillSlots('total_price', basketItem.total_price)
return ctx.tag
示例12: render_basket_item
def render_basket_item(self, ctx, basketItem):
#ctx.tag.fillSlots('thumbnail', T.img(src='/system/ecommerce/%s/mainImage?size=95x150&sharpen=1.0x0.5%%2b0.8%%2b0.1'%basketItem.original.product.id, class_='thumbnail'))
ctx.tag.fillSlots('description', T.xml(basketItem.description))
ctx.tag.fillSlots('unit_price', basketItem.unit_price)
ctx.tag.fillSlots('quantity_ordered', basketItem.quantity_ordered)
ctx.tag.fillSlots('total_price', basketItem.total_price)
return ctx.tag
示例13: flattenIText
def flattenIText(orig, ctx):
assert orig.dom.nodeType == orig.dom.ELEMENT_NODE
assert orig.dom.namespaceURI == 'http://www.w3.org/1999/xhtml'
assert orig.dom.nodeName == 'div'
for node in orig.dom.childNodes:
yield tags.xml(node.toxml())
示例14: render_comment
def render_comment(self, ctx, comment):
tag = ctx.tag
tag.fillSlots("id", comment.id)
tag.fillSlots("posted", comment.posted)
tag.fillSlots("authorName", comment.authorName)
if comment.authorName == 'David Ward':
tag.fillSlots("isOwner", 'owner')
else:
tag.fillSlots("isOwner", '')
tag.fillSlots("authorEmail", comment.authorEmail)
tag.fillSlots("comment", T.xml(markdown.markdown(comment.comment)))
tag.fillSlots("relatesToCommentId",comment.relatesToCommentId)
if hasattr(comment, 'relatesToComment') and comment.relatesToComment is not None:
tag.fillSlots("relatesToCommentName",comment.relatesToComment.authorName)
else:
tag.fillSlots("relatesToCommentName",'main blog entry')
if hasattr(comment,'followUpComments') and comment.followUpComments is not None:
fTag = T.span(class_='followUps')
for f in comment.followUpComments:
fTag[ T.a(href="#comment-%s"%f.id,rel='inspires')[ f.authorName ],', ' ]
tag.fillSlots("followUpComments",fTag)
else:
tag.fillSlots("followUpComments",'None')
return tag
示例15: render_htmlizer
def render_htmlizer(self, ctx, path):
from twisted.python import htmlizer
from StringIO import StringIO
output = StringIO()
htmlizer.filter(open(path), output, writer=htmlizer.SmallerHTMLWriter)
return tags.xml(output.getvalue())