当前位置: 首页>>代码示例>>Python>>正文


Python Page.month_data方法代码示例

本文整理汇总了Python中pages.Page.month_data方法的典型用法代码示例。如果您正苦于以下问题:Python Page.month_data方法的具体用法?Python Page.month_data怎么用?Python Page.month_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pages.Page的用法示例。


在下文中一共展示了Page.month_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from pages import Page [as 别名]
# 或者: from pages.Page import month_data [as 别名]
    def get(self):
     #function defines attributes of five objects: s, n, f, j, m
     #get function print_out to print html
     #get function if statement that defines condition for printing class Delivered attributes

        s = Delivered()#defines class delivered attributes for September
        s.sale1 = 40#how much it cost each sales
        s.sale2 = 69
        s.sale3 = 36
        s.sale4 = 89
        s.sale5 = 24
        s.calc_total()#function to calculate the total of September sales.


        #"November" class delivered variables
        n = Delivered()#defines class delivered attributes for November
        n.sale1 = 50#how much it cost each sales
        n.sale2 = 55
        n.sale3 = 68
        n.sale4 = 93
        n.sale5 = 32
        n.calc_total()#function to calculate the total of November sales.


        #February delivered
        f = Delivered()#defines class delivered attributes for February
        f.sale1 = 24#how much it cost each sales
        f.sale2 = 12
        f.sale3 = 18
        f.sale4 = 84
        f.sale5 = 34
        f.calc_total()#function to calculate the total of February sales.



        j = Delivered()#defines class delivered attributes for June
        j.sale1 = 50#how much it cost each sales
        j.sale2 = 50
        j.sale3 = 50
        j.sale4 = 50
        j.sale5 = 50
        j.calc_total()#function to calculate the total of June sales.


        #May delivered
        m = Delivered()#defines class delivered attributes for May
        m.sale1 = 50#how much it cost each sales
        m.sale2 = 50
        m.sale3 = 50
        m.sale4 = 50
        m.sale5 = 50
        m.calc_total()#function to calculate the total of May sales.



        #call class Page to print in this page
        p = Page()
        self.response.write(p.print_out())

        #if the links are requested, it's print_out_data function called to print the data from the self.month
        if self.request.GET:
        #if we have September after name in url
           if    self.request.GET['name'] == 'september':
                 p.month_data = s #part of the html from class Page that holds the class Delivered attributes for each month
                 title ='s.title'
                 self.response.write(p.print_out_data())# call function print_out_data from class Page to print Delivered attributes.
        #if we have November after name in url
           elif  self.request.GET ['name'] == 'november':
                 p.month_data = n
                 self.response.write('November' + p.print_out_data())
        #if we have February after name in url
           elif  self.request.GET ['name'] == 'february':
                 p.month_data = f
                 self.response.write(p.print_out_data())
        #if we have June after name in url
           elif  self.request.GET ['name'] == 'june':
                 p.month_data = j
                 self.response.write(p.print_out_data())
        #if we have May after name in url
           elif  self.request.GET ['name'] == 'may':
                 p.month_data = m
                 self.response.write(p.print_out_data())
        #if we don't find any of the names above after name in url, just print same page
           else:
                 self.response.write(p.head + p.body + p.close)
        #the print is empty to avoid the same page print twice.
        else:
           self.response.write('')
开发者ID:ednalda,项目名称:Design-Patterns-for-Web-Programming,代码行数:90,代码来源:main.py


注:本文中的pages.Page.month_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。