本文整理匯總了Python中pages.Page.current_animal方法的典型用法代碼示例。如果您正苦於以下問題:Python Page.current_animal方法的具體用法?Python Page.current_animal怎麽用?Python Page.current_animal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pages.Page
的用法示例。
在下文中一共展示了Page.current_animal方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from pages import Page [as 別名]
# 或者: from pages.Page import current_animal [as 別名]
def get(self):
# Establishes variables to allow interaction with designated class.
a1 = Snake()
a2 = Bird()
a3 = Person()
# Stores all animals defined in object
self.animals = [a1, a2, a3]
# Defines p as referring to Page class
p = Page()
# Runs the update command on page to concatinate the first pages info
p.update()
# Listens for an occurance of animal in the browsers request. Essentially listening for a button click
if "animal" in self.request.GET:
# Sets current animals value based on which request was made
p.current_animal = self.animals[int(self.request.GET["animal"])]
# Changes the Title of the page to match the selected animal
p.title = self.animals[int(self.request.GET["animal"])].name
# plays the sound specific for that animal
p.loud_noises = self.animals[int(self.request.GET["animal"])].sound
# Writes contents of whole page to the browser. The update function assembles this
self.response.write(p.whole_page)
else:
self.response.write(p.whole_page)