本文整理汇总了Python中pages.Page类的典型用法代码示例。如果您正苦于以下问题:Python Page类的具体用法?Python Page怎么用?Python Page使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Page类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
def get(self):
p = Page()
lib = FavoriteMovies() #instance for the FavoriteMovies
#movie title (this is part of our assignment, making it user input)
#year movie was made(this is part of our assignment)(this is our assignment)
#director of the film (this is part of our assignment)
#for this demo we will be hard-coding the above three line values do not normally do this
#page for class (if/else for 2 different page views for assignment)
md1 = MovieData()
md1.title = "The Princess Bride"
md1.year = 1989 #actually calling a function
md1.director = "Rob Reiner"
md2 = MovieData()
md2.title = "Dune"
md2.year = 1986 #actually calling a function
md2.director = "David Lynch"
md3 = MovieData()
md3.title = "Star Wars"
md3.year = 1977 #actually calling a function
md3.director = "George Lucas"
#lib.calc_time_span() #adds this to run but we need to add it to the printing out list below
p.body = lib.compile_list() + lib.calc_time_span() #adds the compile list to the body tag of the html in the page.py
self.response.write(p.print_out()) #sends the info out to browser as a big string
示例2: get
def get(self):
#page for class
p = Page()
lib = FavoriteMovies() #lib object
#movie title
#year movie was made
#director of film
md1 = MovieData()
md1.title = "The Princess Bride"
md1.year = 1989 #calling a function
md1.director = "Rob Reiner"
lib.add_movie(md1)
md2 = MovieData()
md2.title = "Dune"
md2.year = 1986 #calling a function
md2.director = "David Lynch"
lib.add_movie(md2)
md2 = MovieData()
md2.title = "Star Wars"
md2.year = 1977 #calling a function
md2.director = "George Lucas"
lib.add_movie(md2)
p.body = lib.compile_list() + lib.calc_time_span()
#lib.movie_list = [md1, md2] = if it was public
self.response.write(p.print_out())
示例3: get
def get(self):
#page for class
p = Page()
lib = FavoriteMovies()
#movie title
#year movie was made
#director of the film
md1 = MovieData()
md1.title = "The Princess Bride"
md1.year = 1989 #actually calling a function
md1.director = "Rob Reiner"
lib.add_movie(md1)
md2 = MovieData()
md2.title = "Dune"
md2.year = 1986 #actually calling a function
md2.director = "David Lynch"
lib.add_movie(md2)
md2 = MovieData()
md2.title = "Star wars"
md2.year = 1977 #actually calling a function
md2.director = "George Lucas"
lib.add_movie(md2)
p.body = lib.compile_list() + lib.calc_time_span()
self.response.write(p.print_out())
def main(name, GPA):
print "The GPA for", name,"is",GPA
return 0
示例4: get
def get(self):
p = Page()
p.title ="My page"
p.css ="css/styles.css"
p.body = "Miss Piggy like Kermit De Frog"
self.response.write(p.whole_page)
示例5: new_index_page
def new_index_page(page_to_copy, page_num, count, total_posts, posts_per_page, path):
index_page = Page()
index_page.copy(page_to_copy)
index_page.url = '/' + path + '/index-%s' % count
index_page.template = template.get_template('post.html')
apply_filter('page-head', index_page)
apply_filter('page-meta', index_page)
apply_filter('page-menu', index_page)
apply_filter('page-foot', index_page)
total_pages = math.ceil(total_posts / posts_per_page) - 1
if page_num > 0:
index_page.template.set_value('prevpage', '<< Newer posts')
if page_num - 1 == 0:
index_page.template.set_attribute('prevpage', 'href', 'index.html')
else:
index_page.template.set_attribute('prevpage', 'href', 'index-%s.html' % (page_num - 1))
if page_num < total_pages:
index_page.template.set_value('nextpage', 'Older posts >>')
index_page.template.set_attribute('nextpage', 'href', 'index-%s.html' % (page_num + 1))
if page_num > 0 and page_num < total_pages:
index_page.template.set_value('pagelinksep', ' | ')
index_page.template.repeat('posts', min(posts_per_page, total_posts - count))
return index_page
示例6: get
def get(self):
# create an instance of the page class - creates a page using this class - it will also call the constructor method
p = Page()
p.title = "MyPage!"
p.body = "Miss piggy loves Kermit da Frog"
self.response.write(p.whole_page)
示例7: get
def get(self):
p = Page()
p.title = "My page!"
p.css = "css/style.css"
p.body = "Miss Piggy likes Kermit De Frog!" #modify body element
self.response.write(p.whole_page)
示例8: get
def get(self):
p = Page()
p.title = "My Page"
p.css = "css/style.css"
p.body = "this is the body"
self.response.write(p.whole_page)
示例9: get
def get(self):
p = Page()# created instance of Page
do = DataObject() #created instance of Data Object
d = Data()
#p.data = d.werewolf.name
self.response.write(p.print_initial())
示例10: go
def go(self, pagename):
current = self.get_current()
if (current != None and
Page.normalize_name(current) == Page.normalize_name(pagename)):
return
if len(self._hst) == 0:
self._hst.append(pagename)
self._pos = 0
return
self._hst = self._hst[0:self._pos+1]
if Page.normalize_name(self._hst[-1]) != Page.normalize_name(pagename):
self._hst.append(pagename)
if len(self._hst) > self.max_items:
self._hst = self._hst[-self.max_items:]
self._pos = len(self._hst) - 1
示例11: get
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())
示例12: get
def get(self):
#create a shortcut to the Page() class
p = Page()
#if the GET method is invoked, grab the form values and set them to the proper keys
if self.request.GET:
#create a shortcut for self.request
sr = self.request
#set the page title.
p.title = "Eric Rogers | Thank You!"
#set the Page().name attribute to the input value submitted.
p.name = sr.GET['name']
#set the Page().telephone attribute to the input value submitted.
p.telephone = sr.GET['telephone']
#set the Page().email attribute to the input value submitted.
p.email = sr.GET['email']
#set the Page().interest attribute to the input value submitted.
p.interest = sr.GET['interest']
#set the Page().return_customer attribute to reflect the user's choice when checked.
p.return_customer = 'Yes, please give me a 10% discount.'
#try to grab the Page().return_customer checkbox value
try:
sr.GET['return_customer']
#if there is no value, the server throws a KeyError meaning the box is not checked.
except KeyError:
#set the Page().return_customer attribute to reflect the user's choice when not checked.
p.return_customer = 'No, I am a new customer.'
#output Page().view2 to the page.
self.response.write(p.view2())
#otherwise, output Page().view1 to the page.
else:
self.response.write(p.view1())
示例13: get
def get(self): #indent here. This function starts everything. below is html5 within the python there is a page head, body and close definied by '''.
p = Page() #I want to make an instance
p.format_all()
if self.request.GET: #has to be in handler
#stores info we got from the form
f_name = self.request.GET['f_name'] #needs variables to work
l_name = self.request.GET['l_name'] #needs variables to work
address = self.request.GET['address']
state = self.request.GET['state']
zip = self.request.GET['zip']
email = self.request.GET['email']
p.email = email
content = self.request.GET['content']
#terms = self.request.GET['terms']
#dropdown = self.request.GET['terms']
self.response.write(p.head + ' ' + p.body + "<div id='wrapper'>"+ "<h3>" "Congratulations on becoming a member of Veronica Vineyards!" + "</h3>" + ' ' + "<div id='name'>" + f_name + ' ' + l_name + "</div>" + "<div id='contact'>" + address + "</div>" + "<div id='state_zip'>" + ' ' + state + ' ' + zip + "</div>" + ' ' + "</br>" + "Look for your email confirmation at:" + ' ' + email + ' ' + "If errors occurred or you would like to update your address please contact us at [email protected]" + "</div>" + p.close) #this is what I want printed whe returned...I'm not sure how to do the css for this?
else:
self.response.write(p.head + p.body + p.close) #prints the information on the page
示例14: process_path
def process_path(path, output_path, pages):
sorted_posts = sorted(filter_pages(path, pages.values()), key=lambda x: x.url[len(path)+1:len(path)+11], reverse=True)
total_posts = len(sorted_posts)
if total_posts == 0:
return
posts_per_page = get_posts_per_page(sorted_posts)
count = 0
page_num = 0
index = 0
if path.startswith('/'):
path = path[1:]
index_page = new_index_page(sorted_posts[0], page_num, count, total_posts, posts_per_page, path)
do_action('post-meta-reset')
for page in sorted_posts:
cpage = Page()
cpage.copy(page)
cpage.template = index_page.template
# TODO: this isn't right, need to fix later
apply_filter('pre-markdown', cpage)
content = apply_filter('markdown', page.content)
cpage.template.set_value('content', content, index)
apply_filter('post-meta', cpage, index)
index += 1
count += 1
if index >= posts_per_page:
write_index_page(index_page, output_path, path, page_num)
do_action('post-meta-reset')
index = 0
page_num += 1
index_page = new_index_page(sorted_posts[0], page_num, count, total_posts, posts_per_page, path)
if index > 0:
write_index_page(index_page, output_path, path, page_num)
示例15: get
def get(self):
p = Page()
p.title = 'My Page!'
p.css = 'css/main.css'
p.body = "Miss Piggy is aweful!"
p.update()
self.response.write(p.whole_page)