本文整理汇总了Python中pages.Page.message方法的典型用法代码示例。如果您正苦于以下问题:Python Page.message方法的具体用法?Python Page.message怎么用?Python Page.message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pages.Page
的用法示例。
在下文中一共展示了Page.message方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from pages import Page [as 别名]
# 或者: from pages.Page import message [as 别名]
def get(self):
# create instance of the view
p = Page()
# create instance of the converter class
u = MetricUnitConverter()
# create instance of the data library class
data = DataHolder()
# if/ else statement to determine which view to throw
if self.request.GET:
# form inputs are stores in the data library
data.name = self.request.GET['name']
data.feet = self.request.GET['feet']
data.inches = self.request.GET['inches']
data.pounds = self.request.GET['weight']
# calculations are returned to the data library
data.meters = u.height_converter(data.feet, data.inches)
data.kilograms = u.weight_converter(data.pounds)
# english BMI requires height to be in inches only
data.total_inches = u.inches_only(data.feet, data.inches)
p.english_bmi = u.english_bmi_calculator(data.pounds, data.total_inches)
p.metric_bmi = u.metric_bmi_calculator(data.kilograms, data.meters)
# name is stored in the data library as well
p.name = data.name
# Custom message is injected into the h1 tag
p.message = "Thanks for filling out our form!"
# generate the results view
self.response.write(p.write_answer())
# else statement to hold the form view (1st view)
else:
# generate the form view (1st view)
self.response.write(p.write_form())