本文整理汇总了Python中nevow.loaders.stan函数的典型用法代码示例。如果您正苦于以下问题:Python stan函数的具体用法?Python stan怎么用?Python stan使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stan函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: render_head_tag
def render_head_tag(self, ctx, data):
ctx.fillSlots('meta_tags', "")
## CSS
stylesheets = []
color_option = self._get_color_option(ctx)
global_css_includes = self.global_css_includes + ['zoto_%s.css' % color_option]
for file in global_css_includes + self.local_css_includes:
stylesheets += [T.link(type="text/css", rel="stylesheet", href=self.make_css_path(file)), '\n']
ctx.fillSlots('css_includes', loaders.stan(T.invisible[stylesheets]))
## alternate links - rss, atom, etc.
feed_links= []
for feed_url in self.global_feed_includes + self.local_feed_includes:
feed_links += [T.link(type="application/%s+xml"%feed_url['type'], rel="alternate", href=feed_url['uri']), '\n']
ctx.fillSlots('feed_includes', loaders.stan(T.invisible[feed_links]))
## Javascript
scripts = []
if aztk_config.setup.get('site', 'environment') in ["sandbox", "development"]:
for script in self.global_js_includes + self.local_js_includes:
if script == "core.js":
for script in js.core_js.scripts:
scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
elif script == "site.js":
for script in js.site_js.scripts:
scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
elif script == "managers.js":
for script in js.managers_js.scripts:
scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
elif script == "mochikit.js":
scripts += [
T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/MochiKit.js")), '\n',
T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/DragAndDrop.js")), '\n',
T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/Sortable.js")), '\n'
]
else:
scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
if self.page_manager_js:
scripts += [T.script(type="text/javascript", src=self.make_js_path(self.page_manager_js)), '\n']
ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts]))
else:
for script in self.global_js_includes + self.local_js_includes:
if script == "mochikit.js":
scripts += [T.script(type="text/javascript", src=self.make_js_path("third_party/MochiKit/packed/MochiKit.js")), '\n']
else:
scripts += [T.script(type="text/javascript", src=self.make_js_path(script)), '\n']
if self.page_manager_js:
scripts += [T.script(type="text/javascript", src=self.make_js_path(self.page_manager_js)), '\n']
ctx.fillSlots('js_includes', loaders.stan(T.invisible[scripts]))
return ctx
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:52,代码来源:zoto_base_page.py
示例3: _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
示例4: test_patterned
def test_patterned(self):
"""Test fetching a specific part (a pattern) of the document.
"""
doc = t.div[t.p[t.span(pattern='inner')['something']]]
df = loaders.stan(doc, pattern='inner')
self.assertEquals(df.load()[0].tagName, 'span')
self.assertEquals(df.load()[0].children[0], 'something')
开发者ID:StetHD,项目名称:nevow,代码行数:7,代码来源:test_loaders.py
示例5: speed
def speed(self, speed):
return rend.Page(
docFactory=loaders.stan(
tags.html[
tags.body(id='body')[
"Thanks for taking our survey! You said: %r %r %r" % (
self.original[0], self.original[1], speed)]]))
开发者ID:exarkun,项目名称:nevow,代码行数:7,代码来源:testformless.py
示例6: test_docFactoryInStanTree
def test_docFactoryInStanTree(self):
class Page(rend.Page):
def __init__(self, included):
self.included = included
rend.Page.__init__(self)
def render_included(self, context, data):
return self.included
docFactory = loaders.stan(div[invisible(render=directive('included'))])
doc = '<p>fum</p>'
temp = self.mktemp()
f = file(temp, 'w')
f.write(doc)
f.close()
result = deferredRender(Page(loaders.stan(p['fee'])))
self.assertEquals(result, '<div><p>fee</p></div>')
result = deferredRender(Page(loaders.htmlstr('<p>fi</p>')))
self.assertEquals(result, '<div><p>fi</p></div>')
result = deferredRender(Page(loaders.xmlstr('<p>fo</p>')))
self.assertEquals(result, '<div><p>fo</p></div>')
result = deferredRender(Page(loaders.htmlfile(temp)))
self.assertEquals(result, '<div><p>fum</p></div>')
result = deferredRender(Page(loaders.xmlfile(temp)))
self.assertEquals(result, '<div><p>fum</p></div>')
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:29,代码来源:test_rend.py
示例7: test_simple
def test_simple(self):
doc = div[p['foo'],p['bar']]
result = unittest.deferredResult(
rend.Page(docFactory=loaders.stan(doc)).renderString()
)
self.assertEquals(result, '<div><p>foo</p><p>bar</p></div>')
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:7,代码来源:test_rend.py
示例8: __init__
def __init__(self, ctx, restWriter, key, srcId):
self.restWriter = restWriter
form = iformal.IForm( ctx )
u = formal_widgetResourceURLFromContext(ctx, form.name).child(key).child( srcId ).child('_submit')
self.destId=srcId + '-dest'
formId=srcId + '-form'
stan = T.html()[
T.head()[
T.script(type="text/javascript")["""
function ReSTTranslate() {
dest = document.getElementById('%(destId)s');
form = document.getElementById('%(formId)s');
src = parent.document.getElementById('%(srcId)s');
dest.value = src.value;
form.submit();
}
"""%{'srcId':srcId, 'destId':self.destId, 'formId':formId}]
],
T.body()[
T.form(id=formId, method="POST", action=u)[
T.input(type="hidden", name=self.destId, id=self.destId)
],
T.script(type="text/javascript")["ReSTTranslate();"],
],
]
self.docFactory = loaders.stan(stan)
开发者ID:timparkin,项目名称:into-the-light,代码行数:30,代码来源:richtext.py
示例9: 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
示例10: render_content
def render_content(self, ctx, data):
request = inevow.IRequest(ctx)
ctx.fillSlots('header_bar', self.anon_header)
ctx.fillSlots('top_bar', T.div(id="top_bar"))
ctx.fillSlots('main_content', loaders.stan(T.div(id="manager_hook")))
return ctx.tag
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:7,代码来源:reset_password.py
示例11: 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
示例12: test_reusedDocFactory
def test_reusedDocFactory(self):
"""
Test that a docFactory which is used more than once behaves properly
both times.
"""
class Page(rend.Page):
docFactory = loaders.stan(div[invisible(render=directive('included'))])
def __init__(self, included):
self.included = included
rend.Page.__init__(self)
def render_included(self, context, data):
return self.included
p1 = Page(loaders.stan('first'))
p2 = Page(loaders.xmlstr('<p>second</p>'))
d = deferredRender(p1)
def rendered(result):
self.assertEqual(result, '<div>first</div>')
return deferredRender(p2)
d.addCallback(rendered)
def renderedAgain(result):
self.assertEqual(result, '<div><p>second</p></div>')
d.addCallback(renderedAgain)
return d
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:29,代码来源:test_rend.py
示例13: test_stanPreprocessors
def test_stanPreprocessors(self):
"""
Test that the stan loader properly passes uncompiled documents to
preprocessors it is given.
"""
factory = loaders.stan(
t.div[t.span['Hello'], t.span['world']])
return self._preprocessorTest(factory)
开发者ID:StetHD,项目名称:nevow,代码行数:8,代码来源:test_loaders.py
示例14: test_synchronousFlatten
def test_synchronousFlatten(self):
"""
Flattening a L{Element} with no Deferreds using the old synchronous
flattener API returns a value synchronously.
"""
element = Element()
element.docFactory = stan(["hello, world"])
self.assertEqual(synchronousFlatten(element), "hello, world")
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:8,代码来源:test_element.py
示例15: test_simpleStanRendering
def test_simpleStanRendering(self):
"""
Test that a Element with a simple, static stan document factory
renders correctly.
"""
f = Element(docFactory=stan(p["Hello, world."]))
return self._render(f).addCallback(
self.assertEqual, "<p>Hello, world.</p>")
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:8,代码来源:test_element.py
示例16: setUp
def setUp(self):
self.d = Deferred()
self.d2 = Deferred()
self.r = rend.Page(docFactory=loaders.stan(
tags.html(data=self.data_later)[
'Hello ', str, ' and '
'goodbye ',str,
tags.span(data=self.data_later2, render=str)]))
开发者ID:perkinslr,项目名称:nevow-py3,代码行数:8,代码来源:test_later.py
示例17: 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
示例18: offerings
def offerings():
for p in self.offeringPlugins.itervalues():
data = {'name': p.name, 'description': p.description}
if p.name not in self.installedOfferings:
f = UninstalledOfferingFragment(data, self.original, p, docFactory=loaders.stan(uninstalled()))
f.page = self.page
else:
f = rend.Fragment(data, docFactory=loaders.stan(installed()))
yield f
开发者ID:fusionapp,项目名称:mantissa,代码行数:9,代码来源:offering.py
示例19: renderPlainFragment
def renderPlainFragment(fragment):
"""
same as L{render}, but expects an L{nevow.rend.Fragment} or any
other L{nevow.inevow.IRenderer}
"""
page = Page(docFactory=stan(fragment))
(request, context) = _makeContext()
page.renderHTTP(context)
return request.v
开发者ID:fusionapp,项目名称:mantissa,代码行数:9,代码来源:rendertools.py
示例20: 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
注:本文中的nevow.loaders.stan函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论