12: Form Get Methods

< Previous Step Next Step >


There are methods in the Form handling classes, responding to HTTP GET requests, that provide the form itself to the user. The methods do this by turning on a switch in the rendering of the template.



# splash page

def splash_page_render (template_values):
# to do: add data to template_values
path = os.path.join(os.path.dirname(__file__), 'splash_page.html')
return template.render(path, template_values)

class SplashPage(webapp.RequestHandler):
def get(self):
pass


# login / logout pages class LoginPage(webapp.RequestHandler): def get(self): pass class LogoutPage(webapp.RequestHandler): def get(self): pass
# user page def user_page_render (template_values): # to do: add data to template_values path = os.path.join(os.path.dirname(__file__), 'user_page.html') return template.render(path, template_values) class UserPage(webapp.RequestHandler): def get(self): pass class CreateGroup(webapp.RequestHandler): def get(self):
template_values = {
'CreateGroupForm': 1
}
self.response.out.write (user_page_render(template_values))

# admin page def admin_page_render (template_values): # to do: add data to template_values path = os.path.join(os.path.dirname(__file__), 'admin_page.html') return template.render(path, template_values) class AdminPage(webapp.RequestHandler): def get(self): pass
# group page def group_page_render (template_values): # to do: add data to template_values path = os.path.join(os.path.dirname(__file__), 'group_page.html') return template.render(path, template_values) class GroupPage(webapp.RequestHandler): def get(self): # state switch: user's membership in group pass class CreateGroup(webapp.RequestHandler): def get(self, key): pass class JoinGroup(webapp.RequestHandler): def get(self):
template_values = {
'JoinGroupForm': 1
}
self.response.out.write (group_page_render(template_values))
class LeaveGroup(webapp.RequestHandler): def get(self):
template_values = {
'LeaveGroupForm': 1
}
self.response.out.write (group_page_render(template_values))

# text sections class TextSectionAddEdit(webapp.RequestHandler): def get(self, key): # add - renders the home page with a # Text form, populateed on edit pass def post(self): # add - handles the CGI POST to # add or update a Text section pass class TextSectionDelete(webapp.RequestHandler): def get(self, key): # delete - deletes a text section pass

Comments