本文整理汇总了Python中pyramid_simpleform.renderers.FormRenderer类的典型用法代码示例。如果您正苦于以下问题:Python FormRenderer类的具体用法?Python FormRenderer怎么用?Python FormRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_select_with_options_obj
def test_select_with_options_obj(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema, defaults={"name": "ValueFred"})
renderer = FormRenderer(form)
options = Options(
[
OptGroup("OptGroup", [Option(value="ValueOG", label="LabelOG")]),
Option(value="ValueFred", label="LabelFred"),
Option(value="ValueBarney", label="LabelBarney"),
Option(value="ValueWilma", label="LabelWilma"),
Option(value="ValueBetty", label="LabelBetty"),
]
)
self.assertTrue(
renderer.select("name", options)
== """<select id="name" name="name">
<optgroup label="OptGroup">
<option value="ValueOG">LabelOG</option>
</optgroup>
<option selected="selected" value="ValueFred">LabelFred</option>
<option value="ValueBarney">LabelBarney</option>
<option value="ValueWilma">LabelWilma</option>
<option value="ValueBetty">LabelBetty</option>
</select>"""
)
示例2: test_begin_form
def test_begin_form(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assert_(renderer.begin(url="/"), '<form action="/" method="post">')
示例3: test_textarea
def test_textarea(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema, defaults={"name": "Fred"})
renderer = FormRenderer(form)
self.assert_(renderer.textarea("name") == '<textarea id="name" name="name">Fred</textarea>')
示例4: test_end_form
def test_end_form(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assertEqual(renderer.end(), "</form>")
示例5: test_hidden
def test_hidden(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema, defaults={"name": "Fred"})
renderer = FormRenderer(form)
self.assert_(renderer.hidden("name") == '<input id="name" name="name" type="hidden" value="Fred" />')
示例6: test_csrf
def test_csrf(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleSchema)
renderer = FormRenderer(form)
self.assert_(renderer.csrf() == \
'<input id="_csrf" name="_csrf" type="hidden" value="csrft" />')
示例7: test_csrf
def test_csrf(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assertEqual(renderer.csrf(),
'<input id="_csrf" name="_csrf" type="hidden" value="0123456789012345678901234567890123456789" />')
示例8: test_label_using_field_name
def test_label_using_field_name(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assert_(renderer.label("name", "Your name") == '<label for="name">Your name</label>')
示例9: test_password
def test_password(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assert_(renderer.password("password") == '<input id="password" name="password" type="password" />')
示例10: test_label
def test_label(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assertTrue(renderer.label("name") == '<label for="name">Name</label>')
示例11: test_file
def test_file(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assert_(renderer.file("file") == '<input id="file" name="file" type="file" />')
示例12: test_csrf_token
def test_csrf_token(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assert_(renderer.csrf_token() == \
'<div style="display:none;"><input id="_csrf" name="_csrf" '
'type="hidden" value="0123456789012345678901234567890123456789" /></div>')
示例13: test_checkbox
def test_checkbox(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema, defaults={"name" : True})
renderer = FormRenderer(form)
self.assert_(renderer.checkbox("name") == \
'<input checked="checked" id="name" name="name" type="checkbox" '
'value="1" />')
示例14: test_submit
def test_submit(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema)
renderer = FormRenderer(form)
self.assert_(renderer.submit("submit", "Submit") == \
'<input id="submit" name="submit" type="submit" value="Submit" />')
示例15: test_date
def test_date(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
import datetime
request = testing.DummyRequest()
form = Form(request, SimpleFESchema, defaults={
"when" : datetime.date(2014, 02, 01) })
renderer = FormRenderer(form)
self.assert_(renderer.date("when", date_format="%d/%m/%Y") == \
'<input id="when" name="when" type="text" value="01/02/2014" />')