lib/page.py
changeset 6 5565d94da522
parent 5 9ed4c7d2bdd2
child 7 d6a8258bd90e
equal deleted inserted replaced
5:9ed4c7d2bdd2 6:5565d94da522
       
     1 
       
     2 class Page (object) :
       
     3     """
       
     4         A page is kind of like a controller, I guess
       
     5     """
       
     6 
       
     7     # the page title, used in the HTML <title>
       
     8     title = None
       
     9 
       
    10     # the page name, used in the menu
       
    11     name = None
       
    12 
       
    13     # the page path, used in the URL
       
    14     path = None
       
    15 
       
    16     # parent page, can be self
       
    17     parent = None
       
    18 
       
    19     # menu of sub-pages, may be empty
       
    20     menu = None
       
    21 
       
    22     def __init__ (self, req, path_suffix) :
       
    23         self.req = req
       
    24         self.path_suffix = path_suffix
       
    25 
       
    26         # default parent to root
       
    27         if not self.parent :
       
    28             from pages import index as index_page
       
    29 
       
    30             self.parent = index_page.Page
       
    31     
       
    32     def _build_template (self, template_class) :
       
    33         tpl = template_class(searchList=[self.req])
       
    34         
       
    35         tpl.page_title = self.title
       
    36         tpl.page_name = self.name
       
    37         tpl.page_path = self.path
       
    38 
       
    39         tpl.page_menu = self.menu
       
    40         tpl.page = self
       
    41         
       
    42         return tpl
       
    43     
       
    44     def get_response_code (self) :
       
    45         """
       
    46             Returns the HTTP response code to be used
       
    47         """
       
    48 
       
    49         return 200
       
    50 
       
    51     def render_template (self) :
       
    52         """
       
    53             Returns an instance of Cheetah.Template, prepopulated with whatever variables it needs, ready to be rendered
       
    54         """
       
    55 
       
    56         abstract
       
    57 
       
    58 
       
    59