本文整理汇总了Python中nevow.tags.slot函数的典型用法代码示例。如果您正苦于以下问题:Python slot函数的具体用法?Python slot怎么用?Python slot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了slot函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render
def render(self, ctx, key, args, errors):
if errors:
value = args.get(key,[None])[0]
else:
if args is not None:
value = iforms.IStringConvertible(self.original).fromType(args.get(key))
def render_node(ctx, data):
tag = ctx.tag
data = self.nodeInterface(data)
tag.fillSlots('value',data.value)
tag.fillSlots('label',data.label)
if str(data.value) == str(value):
tag = tag(checked='checked')
return tag
template = T.div()[
T.input(pattern='item', render=render_node, type='radio', name=key,
value=T.slot('value'))[
T.slot('label')
],
T.input(pattern='itemdisabled', render=render_node,
disabled="disabled", type='radio', name=key,
value=T.slot('value'))[
T.slot('label')
]
]
return T.invisible(data=self.tree, render=tree.render)[template]
开发者ID:timparkin,项目名称:into-the-light,代码行数:30,代码来源:xforms.py
示例2: test_blogsRenderer
def test_blogsRenderer(self):
"""
Test that L{hyperbola_view.BlogListFragment.blogs} renders a list of blogs.
"""
site = self.siteStore.findUnique(SiteConfiguration)
site.hostname = u'blogs.renderer'
blog1 = self._shareAndGetProxy(self._makeBlurb(FLAVOR.BLOG))
blog2 = self._shareAndGetProxy(self._makeBlurb(FLAVOR.BLOG))
blf = hyperbola_view.BlogListFragment(
athena.LivePage(), self.publicPresence)
blf.docFactory = loaders.stan(
tags.div(pattern='blog')[
tags.span[tags.slot('title')],
tags.span[tags.slot('link')],
tags.span[tags.slot('post-url')]])
tag = tags.invisible
markup = flat.flatten(tags.div[blf.blogs(None, tag)])
doc = minidom.parseString(markup)
blogNodes = doc.firstChild.getElementsByTagName('div')
self.assertEqual(len(blogNodes), 2)
for (blogNode, blog) in zip(blogNodes, (blog1, blog2)):
(title, blogURL, postURL) = blogNode.getElementsByTagName('span')
blogURL = blogURL.firstChild.nodeValue
expectedBlogURL = str(websharing.linkTo(blog))
self.assertEqual(blogURL, expectedBlogURL)
postURL = postURL.firstChild.nodeValue
self.assertEqual(
postURL, 'https://blogs.renderer' + expectedBlogURL + '/post')
开发者ID:pombredanne,项目名称:hyperbola,代码行数:29,代码来源:test_view.py
示例3: test_precompiledSlotFilledWithSlot
def test_precompiledSlotFilledWithSlot(self):
"""
A L{_PrecompiledSlot} slot which is filled with another slot is
replaced with the value the other slot is filled with.
"""
tag = invisible[oldPrecompile(div[slot("foo")])]
tag.fillSlots("foo", slot("bar"))
tag.fillSlots("bar", '"&<>')
self.assertStringEqual(self.flatten(tag), '<div>"&<></div>')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:9,代码来源:test_newflat.py
示例4: test_deeplyNestedSlot
def test_deeplyNestedSlot(self):
"""
Flattening succeeds for an object with a level of slot nesting
significantly greater than the Python maximum recursion limit.
"""
tag = div()[slot("foo-0")]
for i in xrange(1000):
tag.fillSlots("foo-" + str(i), slot("foo-" + str(i + 1)))
tag.fillSlots("foo-1000", "bar")
self._nestingTest(tag, "<div>bar</div>")
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:10,代码来源:test_newflat.py
示例5: _render
def _render(self, ctx, key, args, errors, value, tag):
def data_facets(ctx, data):
storeSession = util.getStoreSession(ctx)
avatar = util.getAvatar(ctx)
@defer.deferredGenerator
def loadCategories(facets):
d = defer.waitForDeferred(avatar.getCategoryManager(storeSession))
yield d
categories = d.getResult()
rv = []
for f in facets:
facetData = FacetData()
facetData.label = f[2]
facetData.textid = f[1]
rv.append(facetData)
d = defer.waitForDeferred(categories.loadCategories(facetData.textid))
yield d
facetData.tree = d.getResult().children
yield rv
d = avatar.getCategoryManager(storeSession)
d.addCallback(lambda categories: categories.loadFacets())
d.addCallback(loadCategories)
return d
def render_facet(ctx, data):
tag = ctx.tag
tag.fillSlots("facetlabel", data.label)
return tag
def render_node(ctx, data):
tag = ctx.tag
tag.fillSlots("value", data.path)
tag.fillSlots("label", data.label)
if data.path in value:
tag.children[0] = tag.children[0](checked="checked")
else:
tag.children[0](checked=None)
return tag
template = T.div(class_="categorieswidget")[
T.p(class_="opener")["click to open/close"],
T.ul(class_="panel", data=data_facets, render=rend.sequence)[
T.li(pattern="item", render=render_facet)[
T.slot("facetlabel"),
T.div(data=T.directive("tree"), render=tree.render)[
T.invisible(pattern="item", render=render_node)[tag, T.slot("label")]
],
]
],
]
return T.invisible()[template]
开发者ID:timparkin,项目名称:timparkingallery,代码行数:55,代码来源:categorieswidget.py
示例6: test_reusedDeferredSupport
def test_reusedDeferredSupport(self):
"""
Two occurrences of a particular slot are each replaced with the
result of the Deferred which is used to fill that slot.
"""
doc = tags.html[
tags.slot('foo'), tags.slot('foo')]
doc.fillSlots('foo', defer.succeed(tags.span['Foo!!!']))
self.r = rend.Page(docFactory=loaders.stan(doc))
req = self.renderIt()
self.assertEqual(req.v, '<html><span>Foo!!!</span><span>Foo!!!</span></html>')
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:11,代码来源:test_later.py
示例7: test_slots
def test_slots(self):
tag = tags.html[
tags.body[
tags.table(data={'one': 1, 'two': 2}, render=rend.mapping)[
tags.tr[tags.td["Header one."], tags.td["Header two."]],
tags.tr[
tags.td["One: ", tags.slot("one")],
tags.td["Two: ", tags.slot("two")]
]
]
]
]
self.assertEqual(self.render(tag), "<html><body><table><tr><td>Header one.</td><td>Header two.</td></tr><tr><td>One: 1</td><td>Two: 2</td></tr></table></body></html>")
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:13,代码来源:test_flatstan.py
示例8: test_unfilledPrecompiledSlot
def test_unfilledPrecompiledSlot(self):
"""
Flattening a L{_PrecompiledSlot} for which no value has been supplied
results in an L{FlattenerError} exception.
"""
tag = oldPrecompile(div[slot("foo")])
self.assertRaises(FlattenerError, self.flatten, tag)
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:7,代码来源:test_newflat.py
示例9: test_unfilledSlotDeferredResult
def test_unfilledSlotDeferredResult(self):
"""
Flattening a L{Deferred} which results in an unfilled L{slot} results
in a L{FlattenerError} failure.
"""
return self.assertFailure(
self.deferflatten(succeed(slot("foo"))),
FlattenerError)
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:8,代码来源:test_newflat.py
示例10: test_unfilledSlot
def test_unfilledSlot(self):
"""
Flattening a slot which has no known value results in an
L{FlattenerError} exception which has an L{UnfilledSlot} exception
in its arguments.
"""
exc = self.assertRaises(FlattenerError, self.flatten, slot("foo"))
self.assertTrue(isinstance(exc.args[0], UnfilledSlot))
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:8,代码来源:test_newflat.py
示例11: test_filledSlotTagChildEscaping
def test_filledSlotTagChildEscaping(self):
"""
Flattening a slot as a child of a L{Tag} which has been given a string
value results in that string value being XML escaped in the output.
"""
tag = div[slot("foo")]
tag.fillSlots("foo", '"&<>')
self.assertStringEqual(self.flatten(tag), '<div>"&<></div>')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:8,代码来源:test_newflat.py
示例12: test_precompiledSlot
def test_precompiledSlot(self):
"""
A L{_PrecompiledSlot} is replaced with the value of that slot when
flattened.
"""
tag = invisible[oldPrecompile(div[slot("foo")])]
tag.fillSlots("foo", '"&<>')
self.assertStringEqual(self.flatten(tag), '<div>"&<></div>')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:8,代码来源:test_newflat.py
示例13: test_precompiledSlotTagAttribute
def test_precompiledSlotTagAttribute(self):
"""
A L{_PrecompiledSlot} which is the value of an attribute is replaced
with the value of the slot with XML attribute quoting applied.
"""
tag = invisible[oldPrecompile(div(foo=slot("foo")))]
tag.fillSlots("foo", '"&<>')
self.assertStringEqual(self.flatten(tag), '<div foo=""&<>"></div>')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:8,代码来源:test_newflat.py
示例14: test_slotFilledWithProto
def test_slotFilledWithProto(self):
"""
Filling a slot with a L{Proto} results in the slot being replaced with
the serialized form of the tag in the output.
"""
tag = div[slot("foo")]
tag.fillSlots("foo", br)
self.assertStringEqual(self.flatten(tag), "<div><br /></div>")
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:8,代码来源:test_newflat.py
示例15: test_precompileSlotData
def test_precompileSlotData(self):
"""Test that tags with slotData are not precompiled out of the
stan tree.
"""
tag = tags.p[tags.slot('foo')]
tag.fillSlots('foo', 'bar')
precompiled = self.render(tag, precompile=True)
self.assertEqual(self.render(precompiled), '<p>bar</p>')
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:8,代码来源:test_flatstan.py
示例16: test_filledSlotTagAttribute
def test_filledSlotTagAttribute(self):
"""
Flattening a slot which is the value of an attribute of a L{Tag}
results in the value of the slot appearing as the attribute value in
the output.
"""
tag = div(foo=slot("bar"))
tag.fillSlots("bar", "baz")
self.assertStringEqual(self.flatten(tag), '<div foo="baz"></div>')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:9,代码来源:test_newflat.py
示例17: test_filledSlotNestedTagChild
def test_filledSlotNestedTagChild(self):
"""
Flattening a slot as a child of a L{Tag} which is itself a child of a
L{Tag} which has been given a value for that slot results in the slot
being replaced with the value in the output.
"""
tag = div[div[slot("foo")]]
tag.fillSlots("foo", "bar")
self.assertStringEqual(self.flatten(tag), "<div><div>bar</div></div>")
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:9,代码来源:test_newflat.py
示例18: getTestContainer
def getTestContainer(self):
"""
Return a Nevow DOM object (generally a tag) with a C{widget} slot in
it. This will be used as the top-level DOM for this test case, and the
actual widget will be used to fill the C{widget} slot.
Subclasses may want to override this.
"""
return tags.invisible[tags.slot('widget')]
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:9,代码来源:testcase.py
示例19: render_cssid
def render_cssid(fieldKey, *extras):
"""
Render the CSS id for the form field's key.
"""
l = [tags.slot('formName'), '-', '-'.join(fieldKey.split('.'))]
for extra in extras:
l.append('-')
l.append(extra)
return l
开发者ID:nakedible,项目名称:vpnease-l2tp,代码行数:9,代码来源:util.py
示例20: test_slotsNestedInRenderResult
def test_slotsNestedInRenderResult(self):
"""
A L{slot} in the return value of a render function is replaced by the
value of that slot as found on the tag which had the render directive.
"""
tag = div(render="foo")
tag.fillSlots("bar", '"&<>')
renderable = RenderRenderable([], "foo", tag, slot("bar"))
self.assertStringEqual(self.flatten(renderable), '"&<>')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:9,代码来源:test_newflat.py
注:本文中的nevow.tags.slot函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论