lib/page.py
author Tero Marttila <terom@fixme.fi>
Fri, 06 Feb 2009 20:49:29 +0200
changeset 6 5565d94da522
parent 5 site/page.py@9ed4c7d2bdd2
child 7 d6a8258bd90e
permissions -rw-r--r--
start breaking everything

class Page (object) :
    """
        A page is kind of like a controller, I guess
    """

    # the page title, used in the HTML <title>
    title = None

    # the page name, used in the menu
    name = None

    # the page path, used in the URL
    path = None

    # parent page, can be self
    parent = None

    # menu of sub-pages, may be empty
    menu = None

    def __init__ (self, req, path_suffix) :
        self.req = req
        self.path_suffix = path_suffix

        # default parent to root
        if not self.parent :
            from pages import index as index_page

            self.parent = index_page.Page
    
    def _build_template (self, template_class) :
        tpl = template_class(searchList=[self.req])
        
        tpl.page_title = self.title
        tpl.page_name = self.name
        tpl.page_path = self.path

        tpl.page_menu = self.menu
        tpl.page = self
        
        return tpl
    
    def get_response_code (self) :
        """
            Returns the HTTP response code to be used
        """

        return 200

    def render_template (self) :
        """
            Returns an instance of Cheetah.Template, prepopulated with whatever variables it needs, ready to be rendered
        """

        abstract