本文整理汇总了Python中pyramid_simpleform.renderers.FormRenderer类的典型用法代码示例。如果您正苦于以下问题:Python FormRenderer类的具体用法?Python FormRenderer怎么用?Python FormRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormRenderer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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>"""
)
开发者ID:antoniojesvs,项目名称:pyramid_simpleform,代码行数:30,代码来源:tests.py
示例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">')
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:9,代码来源:tests.py
示例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>')
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:9,代码来源:tests.py
示例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>")
开发者ID:Mr-F,项目名称:pyramid_simpleform,代码行数:9,代码来源:tests.py
示例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" />')
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:9,代码来源:tests.py
示例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" />')
开发者ID:Gutembert-Dev,项目名称:pyramid,代码行数:10,代码来源:tests.py
示例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" />')
开发者ID:Mr-F,项目名称:pyramid_simpleform,代码行数:10,代码来源:tests.py
示例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>')
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:10,代码来源:tests.py
示例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" />')
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:10,代码来源:tests.py
示例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>')
开发者ID:antoniojesvs,项目名称:pyramid_simpleform,代码行数:10,代码来源:tests.py
示例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" />')
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:10,代码来源:tests.py
示例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>')
开发者ID:Mr-F,项目名称:pyramid_simpleform,代码行数:11,代码来源:tests.py
示例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" />')
开发者ID:Mr-F,项目名称:pyramid_simpleform,代码行数:11,代码来源:tests.py
示例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" />')
开发者ID:Mr-F,项目名称:pyramid_simpleform,代码行数:11,代码来源:tests.py
示例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" />')
开发者ID:vsobolmaven,项目名称:pyramid_simpleform,代码行数:12,代码来源:tests.py
示例16: test_hidden_tag_with_just_csrf
def test_hidden_tag_with_just_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.hidden_tag() == \
'<div style="display:none;"><input id="_csrf" name="_csrf" '
'type="hidden" value="csrft" /></div>')
开发者ID:Gutembert-Dev,项目名称:pyramid,代码行数:12,代码来源:tests.py
示例17: test_hidden_tag_with_csrf_and_other_names
def test_hidden_tag_with_csrf_and_other_names(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
form = Form(request, SimpleFESchema, defaults={'name':'foo'})
renderer = FormRenderer(form)
self.assert_(renderer.hidden_tag('name') == \
'<div style="display:none;"><input id="name" name="name" '
'type="hidden" value="foo" /><input id="_csrf" name="_csrf" '
'type="hidden" value="0123456789012345678901234567890123456789" /></div>')
开发者ID:Mr-F,项目名称:pyramid_simpleform,代码行数:13,代码来源:tests.py
示例18: test_is_error
def test_is_error(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
request.method = "POST"
form = Form(request, SimpleFESchema)
self.assert_(not(form.validate()))
renderer = FormRenderer(form)
self.assert_(renderer.is_error('name'))
开发者ID:Mr-F,项目名称:pyramid_simpleform,代码行数:13,代码来源:tests.py
示例19: test_errorlist_with_field
def test_errorlist_with_field(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
request.method = "POST"
form = Form(request, SimpleFESchema)
form.validate()
renderer = FormRenderer(form)
self.assertEqual(renderer.errorlist("name"), '<ul class="error"><li>Missing value</li></ul>')
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:14,代码来源:tests.py
示例20: test_errors_for
def test_errors_for(self):
from pyramid_simpleform import Form
from pyramid_simpleform.renderers import FormRenderer
request = testing.DummyRequest()
request.method = "POST"
form = Form(request, SimpleFESchema)
self.assert_(not (form.validate()))
renderer = FormRenderer(form)
self.assert_(renderer.errors_for("name") == ["Missing value"])
开发者ID:GoodRx,项目名称:pyramid_simpleform,代码行数:14,代码来源:tests.py
注:本文中的pyramid_simpleform.renderers.FormRenderer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论