muyhomepage2 / muyhomepage2 / pagehandlers /

from muyhomepage2 import util

class PageHandler(object):
    def __init__(self, page): = page

    def content(self):
        raise NotImplementedError('PageHandler.content')

    def finalname(self):
        return '%s.html' % util.encodetitle(

    def template(self):
        return None

def handle_action(registry, default, page):
    """ Return a PageHandler object based on the given ``page``'s action
    header. If the action header is not present construct a handler
    based on the ``default``. The value of the action header must map
    to a key in the ``registry`` otherwise.
    if 'action' not in page.headers:
        handler = default
        handler = registry[page.headers['action']]
    return handler(page)