Esempio n. 1
0
# data_copy = get_from_store()
# for each_athlete in data_copy:
#     print(data_copy[each_athlete].name + '' + data_copy[each_athlete].dob)
#===============================================================================

#===============================================================================
# '''
# code of view
# '''
# from chapter7.yate import start_response, include_footer,u_list
# print(start_response())
# print(start_response('text/plain'))
# print(start_response('application/json'))
# print(include_footer({'Home': '/index.html', 'Select': '/cgi-bin/select.py'}))
# print(u_list(['Life of Brian', 'Holy Grail']))
#===============================================================================

import glob
from chapter7 import athletemodel, yate

data_files = glob.glob("data/*.txt")
athletes = athletemodel.put_to_store(data_files)
print(yate.start_response())
print(yate.include_header("Coach Kelly's List of Athletes"))
print(yate.start_form("generating_timeing_data.py"))
print(yate.para("Select an athlete from the list to work with:"))

for each_athlete in athletes:
    print(yate.radio_button("which_athlete", athletes[each_athlete].name))
print(yate.end_form("Select"))
print(yate.include_footer({"Home": "/index.html"}))
'''
Created on 2015年10月5日

@author: zhou
'''
import cgi
from chapter7 import athletemodel, yate
# Get the data from the model
athletes = athletemodel.get_from_store()
# Which athlete's data are you working with?
form_data = cgi.FieldStorage()
athlete_name = form_data['which_athlete'].value

print(yate.start_response())
print(yate.include_header("Coach Kelly's Timing Data"))
print(yate.header("Athlete: " + athlete_name +\
                   ",DOB: " + athletes[athlete_name].dob + "."))
print(yate.para("The top times for this athlete are: "))
print(yate.u_list(athletes[athlete_name].top3()))
print(yate.include_footer({"Home": "/index.html",\
                          "Select another athlete": "geneate_list.py"}))