本文整理汇总了Python中nevow.tags.p函数的典型用法代码示例。如果您正苦于以下问题:Python p函数的具体用法?Python p怎么用?Python p使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了p函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gotSize
def gotSize(size):
quality = ctx.arg('quality')
large = ctx.arg('large',None)
if large is not None:
size = 'size=968x1200&'
quality='100'
else:
size = 'size=600x632&'
if quality is None:
quality = '&quality=60'
linkhref='?quality=93'
enhance=T.p(class_='enhance')['click to enhance']
else:
quality = '&quality=100'
linkhref='?large=True'
enhance = T.p(class_='enhance')['click to see larger']
if large is not None:
enhance = T.p(class_='enhance')['click to return to small view']
linkhref='?quality=93'
if common.isInverted(ctx) is True:
invert='&invert=inverted'
else:
invert=''
imgsrc='/system/ecommerce/%s/mainImage?%ssharpen=1.0x0.5%%2b0.8%%2b0.1%s%s'%(self.photo.id,size,quality,invert)
html = T.a(class_='photo',href=linkhref)[ enhance,T.img(src=imgsrc) ]
return html
示例2: 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)
示例3: data_login_form
def data_login_form(self, ctx, data):
if(self.user):
result = tags.p()[
"You have been successfully logged in as %s" % self.user.username
]
else:
result = tags.form(method="POST")[[
tags.p()['Enter your OpenID identifier to login:'],
tags.label(_for="openid-field")["id:"],
tags.input(type="text", size="60", name="identity"),
tags.input(type="submit", name="submit", value="login"),
]]
return result
示例4: render_section
def render_section(self, ctx, data):
link = url.root.child('section').child(data['sid'])
ctx.tag.fillSlots('title', t.a(href=link)[data['stitle']])
ctx.tag.fillSlots('thread_num', data['thread_num'])
ctx.tag.fillSlots('description', t.p(_class="desc")[data['sdescription']])
ctx.tag.fillSlots('lastMod', pptime(data['lastmod']))
return ctx.tag
示例5: render_footer
def render_footer(self, context, data):
return tags.p() [
tags.div()['Lumen is running on port %s' % lumen.config['port']],
tags.div()[
tags.a(href='http://github.com/unsouled/lumen')['Github']
]
]
示例6: test_data
def test_data(self):
ctx = context.WovenContext()
ctx.remember('foo', inevow.IData)
tag = p(render=rend.data)
self.assertEquals(flat.flatten(tag, ctx), '<p>foo</p>')
ctx.remember('\xc2\xa3'.decode('utf-8'), inevow.IData)
tag = p(render=rend.data)
self.assertEquals(flat.flatten(tag, ctx), '<p>\xc2\xa3</p>')
ctx.remember([1,2,3,4,5], inevow.IData)
tag = p(render=rend.data)
self.assertEquals(flat.flatten(tag, ctx), '<p>12345</p>')
ctx.remember({'foo':'bar'}, inevow.IData)
tag = p(data=directive('foo'), render=rend.data)
self.assertEquals(flat.flatten(tag, ctx), '<p>bar</p>')
示例7: data_info
def data_info(self, ctx, data):
"""
Template function to display basic user info.
"""
return tags.p()[
"authorization information for %s (username '%s')." % (
self.user['first'] + ' ' + self.user['last'],
self.user['username'],
)
]
示例8: _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]
示例9: render_news
def render_news(self, ctx, data):
markup = []
append = markup.append
for i in self.data['news'][:self.countItems]:
append(T.p(_class='datetime')[i['date']])
append(T.h3[i['title']])
for para in i['c'].split('\n'):
if para.strip() == '': continue
append(self._render_para(para))
append('\n')
return markup
示例10: render_section
def render_section(self, ctx, data):
link = url.root.clear().child('section').child(data['sid']).child('')
if data['lastmod']: tm = pptime(data['lastmod'])
else: tm = "-"
if data['thread_num']: n = data['thread_num']
else: n = "0"
ctx.tag.fillSlots('title', t.a(href=link)[data['stitle']])
ctx.tag.fillSlots('thread_num', n)
ctx.tag.fillSlots('description', t.p(_class="desc")[data['sdescription']])
ctx.tag.fillSlots('lastMod', tm)
return ctx.tag
示例11: 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
示例12: render_preview
def render_preview(self, context, data):
docstring = parse_str(self.docstring)
stan, errors = epydoc2stan.doc2html(
self.ob, docstring=docstring)
if self.isPreview or errors:
if errors:
tag = context.tag
#print stan, errors
#assert isinstance(stan, tags.pre)
[text] = stan.children
lines = text.replace('\r\n', '\n').split('\n')
line2err = {}
for err in errors:
if isinstance(err, str):
ln = None
else:
ln = err.linenum()
line2err.setdefault(ln, []).append(err)
w = len(str(len(lines)))
for i, line in enumerate(lines):
i += 1
cls = "preview"
if i in line2err:
cls += " error"
tag[tags.pre(class_=cls)["%*s"%(w, i), ' ', line]]
for err in line2err.get(i, []):
tag[tags.p(class_="errormessage")[err.descr()]]
i += 1
for err in line2err.get(i, []):
tag[tags.p(class_="errormessage")[err.descr()]]
items = []
for err in line2err.get(None, []):
items.append(tags.li[str(err)])
if items:
tag[tags.ul[items]]
else:
tag = context.tag[stan]
return tag[tags.h2["Edit"]]
else:
return ()
示例13: test_missingRenderMethod
def test_missingRenderMethod(self):
"""
Test that flattening an L{Element} with a C{docFactory} which has a tag
with a render directive fails with L{FlattenerError} if there is no
available render method to satisfy that directive.
"""
element = Element(docFactory=stan(p(render=directive('renderMethod'))))
def cb(ignored):
# The old flattener unconditionally logs errors.
self.flushLoggedErrors(MissingRenderMethod)
d = self.assertFailure(self._render(element), FlattenerError)
d.addCallback(cb)
return d
示例14: test_elementContainingStaticElement
def test_elementContainingStaticElement(self):
"""
Test that a Element which is returned by the render method of another
Element is rendered properly.
"""
class RenderfulElement(Element):
def renderMethod(self, request, tag):
return tag[Element(docFactory=stan("Hello, world."))]
renderer(renderMethod)
f = RenderfulElement(
docFactory=stan(p(render=directive('renderMethod'))))
return self._render(f).addCallback(
self.assertEqual, "<p>Hello, world.</p>")
示例15: helpLister
def helpLister(context, data):
ret = []
for label, noteex, eachList in help:
ret.append(T.h4 [ label.encode('utf-8')] )
for i in noteex:
if type(i) == type("") or type(i) is unicode:
ret.append(T.p(class_="note") [ i.encode('utf-8') ])
else:
ret.append(processEx(i))
ret.append(processTable(eachList))
return ret