本文整理汇总了Python中gluon.sqlhtml.SQLFORM.xml方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.xml方法的具体用法?Python SQLFORM.xml怎么用?Python SQLFORM.xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.sqlhtml.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.xml方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_represent_SQLFORM
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import xml [as 别名]
def test_represent_SQLFORM(self):
self.db.t0.tt.represent = lambda value: value.capitalize()
self.db.t0.tt.writable = False
self.db.t0.tt.readable = True
form = SQLFORM(self.db.t0)
self.assertTrue(b'Web2py' in form.xml())
self.db.t0.tt.represent = lambda value, row: value.capitalize()
form = SQLFORM(self.db.t0)
self.assertTrue(b'Web2py' in form.xml())
示例2: test_SQLFORM
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import xml [as 别名]
def test_SQLFORM(self):
form = SQLFORM(self.db.auth_user)
self.assertEqual(form.xml()[:5], b'<form')
示例3: test_SQLFORM
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import xml [as 别名]
def test_SQLFORM(self):
form = SQLFORM(self.db.auth_user)
self.assertEqual(form.xml(), b'<form action="#" enctype="multipart/form-data" method="post"><table><tr id="auth_user_first_name__row"><td class="w2p_fl"><label class="" for="auth_user_first_name" id="auth_user_first_name__label">First name: </label></td><td class="w2p_fw"><input class="string" id="auth_user_first_name" name="first_name" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_last_name__row"><td class="w2p_fl"><label class="" for="auth_user_last_name" id="auth_user_last_name__label">Last name: </label></td><td class="w2p_fw"><input class="string" id="auth_user_last_name" name="last_name" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_email__row"><td class="w2p_fl"><label class="" for="auth_user_email" id="auth_user_email__label">E-mail: </label></td><td class="w2p_fw"><input class="string" id="auth_user_email" name="email" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_username__row"><td class="w2p_fl"><label class="" for="auth_user_username" id="auth_user_username__label">Username: </label></td><td class="w2p_fw"><input class="string" id="auth_user_username" name="username" type="text" value="" /></td><td class="w2p_fc"></td></tr><tr id="auth_user_password__row"><td class="w2p_fl"><label class="" for="auth_user_password" id="auth_user_password__label">Password: </label></td><td class="w2p_fw"><input class="password" id="auth_user_password" name="password" type="password" value="" /></td><td class="w2p_fc"></td></tr><tr id="submit_record__row"><td class="w2p_fl"></td><td class="w2p_fw"><input type="submit" value="Submit" /></td><td class="w2p_fc"></td></tr></table></form>')
示例4: IS_IN_SET
# 需要导入模块: from gluon.sqlhtml import SQLFORM [as 别名]
# 或者: from gluon.sqlhtml.SQLFORM import xml [as 别名]
db.person.sex.requires = IS_IN_SET({'M': 'Male', 'F': 'Female'})
# create the wxPython GUI application instance:
app = wx.App(False)
# create a testing frame (wx "window"):
f = wx.Frame(None, title="web2py/gui2py sample app")
# create the web2py FORM based on person table
form = SQLFORM(db.person)
# create the HTML "browser" window:
html = wx.html.HtmlWindow(f, style= wx.html.HW_DEFAULT_STYLE | wx.TAB_TRAVERSAL)
# convert the web2py FORM to XML and display it
html.SetPage(form.xml())
def on_form_submit(evt):
"Handle submit button user action"
global form
print "Submitting to %s via %s with args %s"% (evt.form.action, evt.form.method, evt.args)
if form.accepts(evt.args, formname=None, keepvalues=False, dbio=False):
print "accepted!"
# insert the record in the table (if dbio=True this is done by web2py):
db.person.insert(name=form.vars.name,
sex=form.vars.sex,
active=form.vars.active,
bio=form.vars.bio,
)
# don't forget to commit, we aren't inside a web2py controller!
db.commit()