本文整理汇总了Python中genshi.input.HTML.render方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.render方法的具体用法?Python HTML.render怎么用?Python HTML.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类genshi.input.HTML
的用法示例。
在下文中一共展示了HTML.render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fill_input_password_enabled
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_input_password_enabled(self):
html = HTML("""<form><p>
<input type="password" name="pass" />
</p></form>""") | HTMLFormFiller(data={'pass': '1234'}, passwords=True)
self.assertEquals("""<form><p>
<input type="password" name="pass" value="1234"/>
</p></form>""", html.render())
示例2: test_fill_input_hidden_multi_value
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_input_hidden_multi_value(self):
html = HTML("""<form><p>
<input type="hidden" name="foo" />
</p></form>""") | HTMLFormFiller(data={'foo': ['bar']})
self.assertEquals("""<form><p>
<input type="hidden" name="foo" value="bar"/>
</p></form>""", html.render())
示例3: test_fill_input_hidden_no_value
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_input_hidden_no_value(self):
html = HTML("""<form><p>
<input type="hidden" name="foo" />
</p></form>""") | HTMLFormFiller()
self.assertEquals("""<form><p>
<input type="hidden" name="foo"/>
</p></form>""", html.render())
示例4: test_fill_input_checkbox_single_value_auto_no_value
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_input_checkbox_single_value_auto_no_value(self):
html = HTML("""<form><p>
<input type="checkbox" name="foo" />
</p></form>""") | HTMLFormFiller()
self.assertEquals("""<form><p>
<input type="checkbox" name="foo"/>
</p></form>""", html.render())
示例5: test_fill_textarea_no_value
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_textarea_no_value(self):
html = HTML("""<form><p>
<textarea name="foo"></textarea>
</p></form>""") | HTMLFormFiller()
self.assertEquals("""<form><p>
<textarea name="foo"/>
</p></form>""", html.render())
示例6: test_fill_textarea_multi_value
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_textarea_multi_value(self):
html = HTML("""<form><p>
<textarea name="foo"></textarea>
</p></form>""") | HTMLFormFiller(data={'foo': ['bar']})
self.assertEquals("""<form><p>
<textarea name="foo">bar</textarea>
</p></form>""", html.render())
示例7: test_fill_input_password_disabled
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_input_password_disabled(self):
html = HTML("""<form><p>
<input type="password" name="pass" />
</p></form>""") | HTMLFormFiller(data={'pass': 'bar'})
self.assertEquals("""<form><p>
<input type="password" name="pass"/>
</p></form>""", html.render())
示例8: test_fill_input_text_single_value
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_input_text_single_value(self):
html = HTML("""<form><p>
<input type="text" name="foo" />
</p></form>""") | HTMLFormFiller(data={'foo': 'bar'})
self.assertEquals("""<form><p>
<input type="text" name="foo" value="bar"/>
</p></form>""", html.render())
示例9: test_fill_textarea_preserve_original
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_textarea_preserve_original(self):
html = HTML("""<form><p>
<textarea name="foo"></textarea>
<textarea name="bar">Original value</textarea>
</p></form>""") | HTMLFormFiller(data={'foo': 'Some text'})
self.assertEquals("""<form><p>
<textarea name="foo">Some text</textarea>
<textarea name="bar">Original value</textarea>
</p></form>""", html.render())
示例10: test_fill_option_unicode_value
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_option_unicode_value(self):
html = HTML("""<form>
<select name="foo">
<option value="ö">foo</option>
</select>
</form>""") | HTMLFormFiller(data={'foo': 'ö'})
self.assertEquals("""<form>
<select name="foo">
<option value="ö" selected="selected">foo</option>
</select>
</form>""", html.render(encoding=None))
示例11: test_fill_textarea_multiple
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_textarea_multiple(self):
# Ensure that the subsequent textarea doesn't get the data from the
# first
html = HTML("""<form><p>
<textarea name="foo"></textarea>
<textarea name="bar"></textarea>
</p></form>""") | HTMLFormFiller(data={'foo': 'Some text'})
self.assertEquals("""<form><p>
<textarea name="foo">Some text</textarea>
<textarea name="bar"/>
</p></form>""", html.render())
示例12: save
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def save(self, encoding=None):
"""validate incoming html using genshi's HTMLSanitizer, throw an error if invalid (ie: anything changed in input)"""
# let creole content go through unverified, the parser will clean it up anyway
if self.blob.markup_language == 'ductus-html5':
html = HTML(self.text)
#TODO: define our own set of acceptable tags/attributes in settings.py
friendly_attrs = set(['data-gentics-aloha-repository', 'data-gentics-aloha-object-id', 'data-macro-name', 'data-tags', 'contenteditable'])
sanitizer = HTMLSanitizer(safe_attrs=HTMLSanitizer.SAFE_ATTRS | friendly_attrs)
safe_html = html | sanitizer
if html.render() != safe_html.render():
raise ValidationError(u'invalid html content')
return super(Wikitext, self).save(encoding)
示例13: test_fill_select_no_value_auto
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_select_no_value_auto(self):
html = HTML(u"""<form><p>
<select name="foo">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</p></form>""") | HTMLFormFiller()
self.assertEquals("""<form><p>
<select name="foo">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</p></form>""", html.render())
示例14: test_fill_select_no_value_defined
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_select_no_value_defined(self):
html = HTML("""<form><p>
<select name="foo">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p></form>""") | HTMLFormFiller()
self.assertEquals("""<form><p>
<select name="foo">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</p></form>""", html.render())
示例15: test_fill_select_single_value_auto
# 需要导入模块: from genshi.input import HTML [as 别名]
# 或者: from genshi.input.HTML import render [as 别名]
def test_fill_select_single_value_auto(self):
html = HTML("""<form><p>
<select name="foo">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
</p></form>""") | HTMLFormFiller(data={'foo': '1'})
self.assertEquals("""<form><p>
<select name="foo">
<option selected="selected">1</option>
<option>2</option>
<option>3</option>
</select>
</p></form>""", html.render())