Source

pist / pist / core.py

from tornado import web

class BaseHandler(web.RequestHandler):

    def __init__(self, *args, **kwargs):
        super(BaseHandler, self).__init__(*args, **kwargs)
        self.context = {}

    def render(self, template, **kwargs):
        """Renders the specified template using our context variables"""

        self.context.update(kwargs)
        return super(BaseHandler, self).render(template, **self.context)

    def get_error_html(self, status_code, **kwargs):
        """Returns the HTML from a template whose name matches the status code"""

        self.context['errors'] = []
        self.context['status_code'] = status_code
        self.context.update(kwargs)

        self._finished = False
        return self.render_string('%s.html' % status_code, **self.context)

class HomeHandler(BaseHandler):

    def get(self):
        return self.render('home.html')