本文整理汇总了Python中nevow.tags.directive函数的典型用法代码示例。如果您正苦于以下问题:Python directive函数的具体用法?Python directive怎么用?Python directive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了directive函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render
def render(self, data):
r = []
i = 0
vlanlist = []
notpresent = T.td(_class="notpresent")[
T.acronym(title="Not present or no information from remote")["N/A"]]
for row in data:
if row[1] is not None:
vlanlist.append(str(row[0]))
vid = T.td[T.span(data=row[0], render=T.directive("vlan"))]
if row[1] is None:
r.append(T.tr(_class=(i%2) and "odd" or "even")[
vid, notpresent,
T.td[row[2]]])
elif row[2] is None:
r.append(T.tr(_class=(i%2) and "odd" or "even")
[vid, T.td[row[1]], notpresent])
elif row[1] == row[2]:
r.append(T.tr(_class=(i%2) and "odd" or "even")
[vid, T.td(colspan=2)[row[1]]])
else:
r.append(T.tr(_class=(i%2) and "odd" or "even")
[vid, T.td[row[1]], T.td[row[2]]])
i += 1
vlantable = T.table(_class="vlan")[
T.thead[T.td["VID"], T.td["Local"], T.td["Remote"]], r]
return [('VLAN',
[[ [T.span(data=v, render=T.directive("vlan")), " "]
for v in vlanlist ],
T.span(render=T.directive("tooltip"),
data=vlantable)],
", ".join(vlanlist))]
开发者ID:GennadySpb,项目名称:wiremaps,代码行数:32,代码来源:ports.py
示例2: render_middle
def render_middle(self, context, data):
yield T.div(render=T.directive('trail'), data=data.get_ancestry())
yield T.h1(class_='main-heading')[data.title]
yield T.div(render=T.directive('items'), data=data.get_subdirs())
yield T.div(render=T.directive('rst'))
yield T.div(render=T.directive('items'), data=data.get_items())
开发者ID:BackupTheBerlios,项目名称:pida-svn,代码行数:9,代码来源:www.py
示例3: test_directiveComparison
def test_directiveComparison(self):
"""
Test that only directives with the same name compare equal.
"""
foo = tags.directive("foo")
foo2 = tags.directive("foo")
bar = tags.directive("bar")
self.assertEquals(foo, foo)
self.assertEquals(foo, foo2)
self.failIfEqual(foo, bar)
开发者ID:jonathanj,项目名称:nevow,代码行数:10,代码来源:test_tags.py
示例4: _doubleLiveSerialization
def _doubleLiveSerialization(self, cls, renderer):
livePage = DummyLivePage()
liveFragment = cls(
docFactory=loaders.stan(
[tags.div(render=tags.directive(renderer))['Hello'],
tags.div(render=tags.directive('foo'))]))
liveFragment.setFragmentParent(livePage)
self.assertEqual(
json.serialize(liveFragment),
json.serialize(liveFragment))
开发者ID:StetHD,项目名称:nevow,代码行数:10,代码来源:test_json.py
示例5: test_directiveComparison
def test_directiveComparison(self):
"""
Test that only directives with the same name compare equal.
"""
foo = tags.directive('foo')
foo2 = tags.directive('foo')
bar = tags.directive('bar')
self.assertEqual(foo, foo)
self.assertEqual(foo, foo2)
self.assertNotEqual(foo, bar)
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:10,代码来源:test_tags.py
示例6: render_macif
def render_macif(self, ctx, data):
if not data:
return ctx.tag["I did not find this MAC on any interface."]
return ctx.tag["This MAC was found on the following interfaces: ",
T.ul [ [ T.li[
T.invisible(data=l[0],
render=T.directive("hostname")),
" (", T.invisible(data=l[1],
render=T.directive("ip")), ") "
"interface ", T.span(_class="data") [ l[2] ] ]
for l in data] ] ]
开发者ID:GennadySpb,项目名称:wiremaps,代码行数:11,代码来源:search.py
示例7: render_images
def render_images(self, ctx, data):
"""Render a list of images.
"""
tag = T.div(data=images, render=rend.sequence)[
T.div(pattern='item')[
T.p(data=T.directive('filename'), render=T.directive('data')),
T.ul(data=T.directive('comments'), render=rend.sequence)[
T.li(pattern='item', render=T.directive('data')),
],
],
]
return tag
开发者ID:BackupTheBerlios,项目名称:cuon-svn,代码行数:12,代码来源:server_web2.py
示例8: test_directiveHashing
def test_directiveHashing(self):
"""
Test that only directives with the same name hash to the same thing.
"""
foo = tags.directive("foo")
foo2 = tags.directive("foo")
bar = tags.directive("bar")
self.assertEquals(hash(foo), hash(foo2))
# XXX What if 'foo' and 'bar' accidentally hash equal in some version
# of Python?
self.failIfEqual(hash(foo), hash(bar))
开发者ID:jonathanj,项目名称:nevow,代码行数:12,代码来源:test_tags.py
示例9: renderOnce
def renderOnce(fragmentClass):
"""
Create L{DEPTH} LiveFragments, each nested within the next, and then render
the result.
"""
rname = fragmentClass.__name__[0].lower() + fragmentClass.__name__[1:]
innerFragment = fragmentClass(docFactory=stan(p(render=directive(rname))["Hello, world."]))
for i in xrange(DEPTH - 1):
outerFragment = fragmentClass(docFactory=stan(p(render=directive(rname))[innerFragment]))
innerFragment.setFragmentParent(outerFragment)
innerFragment = outerFragment
render(outerFragment)
开发者ID:pombredanne,项目名称:quotient,代码行数:12,代码来源:benchmark_livefragment.py
示例10: render_macfdb
def render_macfdb(self, ctx, data):
if not data:
return ctx.tag["I did not find this MAC on any FDB entry."]
return ctx.tag["This MAC was found in FDB of the following equipments: ",
T.ul [ [ T.li[
T.invisible(data=l[0],
render=T.directive("hostname")),
" (", T.invisible(data=l[1],
render=T.directive("ip")), ") "
"on port ", T.span(_class="data") [ l[2] ],
" (out of %d MAC address%s)" % (l[4], l[4]>1 and "es" or "") ]
for l in data] ] ]
开发者ID:GennadySpb,项目名称:wiremaps,代码行数:12,代码来源:search.py
示例11: getWidgetDocument
def getWidgetDocument(self):
# XXX No support for rendering these yet!
f = liveform.LiveForm(
self.submit,
[liveform.Parameter('argument', None, unicode)])
f.docFactory = loaders.stan(tags.form(render=tags.directive('liveElement'))[
tags.select(name="argument")[
tags.option(value="apples")["apples"],
tags.option(value="oranges")["oranges"]],
tags.input(type='submit', render=tags.directive('submitbutton'))])
f.setFragmentParent(self)
return f
开发者ID:fusionapp,项目名称:mantissa,代码行数:12,代码来源:livetest_forms.py
示例12: render_sonmp
def render_sonmp(self, ctx, data):
if not data:
return ctx.tag["This IP has not been seen with SONMP."]
return ctx.tag["This IP has been seen with SONMP: ",
T.ul[ [ T.li [
"from port ",
T.span(_class="data") [d[1]],
" of ",
T.span(data=d[0],
render=T.directive("hostname")),
" connected to port ",
T.span(data=d[2], _class="data",
render=T.directive("sonmpport")) ] for d in data] ] ]
开发者ID:GennadySpb,项目名称:wiremaps,代码行数:13,代码来源:search.py
示例13: _renderPage
def _renderPage():
page = MantissaLivePage(FakeWebSite())
element = LiveElement(stan(tags.span(render=tags.directive('liveElement'))))
element.setFragmentParent(page)
element.jsClass = u'Mantissa.Test.Dummy.DummyWidget'
page.docFactory = stan([tags.span(render=tags.directive('liveglue')), element])
ctx = WovenContext()
req = FakeRequest(headers={'host': self.hostname})
ctx.remember(req, IRequest)
page.beforeRender(ctx)
page.renderHTTP(ctx)
page._messageDeliverer.close()
开发者ID:twisted,项目名称:mantissa,代码行数:13,代码来源:test_website.py
示例14: render_ipeqt
def render_ipeqt(self, ctx, data):
if not data:
return ctx.tag["The IP ",
T.span(data=self.ip,
render=T.directive("ip")),
" is not owned by a known equipment."]
return ctx.tag["The IP ",
T.span(data=self.ip,
render=T.directive("ip")),
" belongs to ",
T.span(data=data[0][0],
render=T.directive("hostname")),
"."]
开发者ID:GennadySpb,项目名称:wiremaps,代码行数:13,代码来源:search.py
示例15: render_discovery
def render_discovery(self, ctx, data):
if not data:
return ctx.tag["This IP has not been seen with %s." % self.discovery_name]
return ctx.tag["This IP has been seen with %s: " % self.discovery_name,
T.ul [ [ T.li [
"from port ",
T.span(_class="data") [d[1]],
" of ",
T.span(data=d[0],
render=T.directive("hostname")),
" connected to port ",
T.span(_class="data") [d[2]],
" of ",
T.span(data=d[3],
render=T.directive("hostname"))] for d in data] ] ]
开发者ID:GennadySpb,项目名称:wiremaps,代码行数:15,代码来源:search.py
示例16: doRendering
def doRendering(self, fragmentClass):
"""
Verify that the given fragment class will render without raising an
exception.
"""
siteStore = Store()
loginSystem = LoginSystem(store=siteStore)
installOn(loginSystem, siteStore)
p = Product(
store=siteStore, types=["xmantissa.webadmin.LocalUserBrowser", "xmantissa.signup.SignupConfiguration"]
)
account = loginSystem.addAccount(u"testuser", u"localhost", None)
p.installProductOn(account.avatars.open())
f = fragmentClass(None, u"testuser", account)
p = LivePage(docFactory=stan(html[head(render=directive("liveglue")), body(render=lambda ctx, data: f)]))
f.setFragmentParent(p)
ctx = WovenContext()
req = FakeRequest()
ctx.remember(req, IRequest)
d = p.renderHTTP(ctx)
def rendered(ign):
p.action_close(None)
d.addCallback(rendered)
return d
开发者ID:fusionapp,项目名称:mantissa,代码行数:30,代码来源:test_admin.py
示例17: render_head
def render_head(self, ctx, data):
"""
Put liveglue content into the header of this page to activate it, but
otherwise delegate to my parent's renderer for <head>.
"""
ctx.tag[tags.invisible(render=tags.directive('liveglue'))]
return _PublicPageMixin.render_head(self, ctx, data)
开发者ID:rcarmo,项目名称:divmod.org,代码行数:7,代码来源:publicweb.py
示例18: renderHTTP
def renderHTTP(self, ctx):
self.setup()
#ensure that we are delivered with the correct content type header
inevow.IRequest(ctx).setHeader("Content-Type",
"application/vnd.mozilla.xul+xml; charset=%s" % (self.charset,))
#Do something a bit magical.. glue css/js stuff into the window before
#any other widgets so they get read first.
if self.css is not None:
self.window.children.insert(0,
htmlns.style(type="text/css")[self.css])
self.css = None
for css in self.cssIncludes:
self.window.children.insert(0,
htmlns.style(type="text/css", src=css))
self.cssIncludes = []
if self.js is not None:
self.window.children.insert(0,
htmlns.script(type="text/javascript")[self.js])
self.js = None
for js in self.jsIncludes:
self.window.children.insert(0,
htmlns.script(type="text/javascript", src=js))
self.jsIncludes = []
#We want to have javascript included in this order:
# preLiveglue.js
# liveglue.js
# postLiveglue.ps
if not self.glueInstalled:
self.window.children.insert(0, htmlns.script(
type="text/javascript", src=url.here.child(
'javascript').child('postLiveglue.js')))
self.window.children.insert(0, T.invisible(
render=T.directive('liveglue')))
self.window.children.insert(0, htmlns.script(
type="text/javascript", src=url.here.child(
'javascript').child('preLiveglue.js')))
self.glueInstalled = True
#.. end magical
#make sure our XUL tree is loaded and our correct doc type is set
self.docFactory = loaders.stan([
T.xml("""<?xml version="1.0"?><?xml-stylesheet href="chrome://global/skin/" type="text/css"?>"""),
self.window])
#return our XUL
return athena.LivePage.renderHTTP(self, ctx)
开发者ID:BackupTheBerlios,项目名称:nufox-svn,代码行数:58,代码来源:xul.py
示例19: test_synchronousFlattenError
def test_synchronousFlattenError(self):
"""
If the old flattener encounters an exception while flattening an
L{IRenderable}, the exception is raised to the caller of the flattener
API.
"""
element = Element()
element.docFactory = stan(invisible(render=directive('foo')))
self.assertRaises(FlattenerError, synchronousFlatten, element)
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:9,代码来源:test_element.py
示例20: render_dns
def render_dns(self, ctx, name):
try:
name = str(name[0][0].payload.name)
except:
return ctx.tag["This IP has no known name in DNS."]
return ctx.tag["This IP is associated to ",
T.span(data=name,
render=T.directive("hostname")),
" in DNS."]
开发者ID:GennadySpb,项目名称:wiremaps,代码行数:9,代码来源:search.py
注:本文中的nevow.tags.directive函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论