lib/handler.py
changeset 9 2a47b00f60b0
parent 8 0ce1f471e9d7
child 10 d83b10c210e3
equal deleted inserted replaced
8:0ce1f471e9d7 9:2a47b00f60b0
     1 """
     1 """
     2     The actual application behaviour, i.e. generating a Response from a Request :)
     2     The actual application behaviour, i.e. generating a Response from a Request :)
     3 """
     3 """
     4 
     4 
     5 import http, page, template
     5 import http, page, menu, template
     6 
     6 
     7 def handle_request (request) :
     7 def handle_request (request) :
     8     """
     8     """
     9         Take the Request, and return a Response
     9         Take the Request, and return a Response
    10     """
    10     """
    16     p = page.lookup(page_name)
    16     p = page.lookup(page_name)
    17 
    17 
    18     # render the template
    18     # render the template
    19     response_data = template.render("layout",
    19     response_data = template.render("layout",
    20         site_root_url   = request.get_script_dir(),
    20         site_root_url   = request.get_script_dir(),
    21         page_title      = p.get_title(),
    21         page            = p,
    22         page_content    = p.get_content(),
    22         menu            = menu.Menu(p),
    23     )
    23     )
    24     
    24     
    25     # return the response
    25     # return the response
    26     return http.Response(response_data)
    26     return http.Response(response_data)
    27 
    27