本文整理汇总了Python中form.Form.print_contents方法的典型用法代码示例。如果您正苦于以下问题:Python Form.print_contents方法的具体用法?Python Form.print_contents怎么用?Python Form.print_contents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类form.Form
的用法示例。
在下文中一共展示了Form.print_contents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from form import Form [as 别名]
# 或者: from form.Form import print_contents [as 别名]
def get(self):
if self.request.GET:
# Creating empty sting variable that will later be used to populate form values onto the page.
relationship = ''
# Using try: to prevent checkbox errors
try:
# Set relationship_type equal to the value of the 'relationship1' checkbox if checked
relationship_type = self.request.GET['relationship1']
# If the person did check the 'relationship1' checkbox
if relationship_type:
# Then set empty string variable equal to itself plus the new relationship variable type which will be equal to the checkbox 'relationship1'
relationship = relationship + relationship_type + ' '
# If they check neither box no error will happen
except StandardError:
pass
# Using try: to prevent checkbox errors
try:
# Set relationshiip_type2 equal to the value of the "relationship2" checkbox if checked
relationship_type2 = self.request.GET['relationship2']
# If the person did check the 'relationship2' checkbox
if relationship_type2:
# Then set empty string variable equal to itself plus the new relationship variable type which will be equal to the checkbox 'relationship2'
# Also because of this both can be checked
relationship = relationship + relationship_type2
# If they check neither box no error will happen
except StandardError:
pass
# Set variable form_info equal to all the user inputed form information
form_info = self.request.GET['first_name'] + ' ' + self.request.GET['last_name'] + ' ' + self.request.GET['phone_type'] + ' ' + self.request.GET['phone_number'] + ' ' + relationship
# Creates form Object
form = Form(self)
# Will populate the user inputed information on a new Form Page
self.response.write(form.print_contents(form_info))
else:
# Creates form Object
form = Form(self)
# Will populate the form for the user to input it's information
self.response.write(form.print_contents())