wsgi.py
author Tero Marttila <terom@fixme.fi>
Mon, 16 Feb 2009 02:49:06 +0200
changeset 135 19ff083c2870
parent 134 fbccc1648d79
permissions -rw-r--r--
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
"""
    Our custom WSGI application
"""

from qmsk.web import wsgi

import urls, error

# our custom app with custom error() method
class Application (wsgi.Application) :
    def __init__ (self) :
        """
            Construct wsgi.Application with our URLMapper
        """

        super(Application, self).__init__(urls.mapper)
    
    def handle_error (self, exc_info, env, start_response) :
        """
            Use error.build_error and return that
        """
        
        # get info
        status, content_type, body = error.build_error(env=env)

        # headers
        start_response(status, [('Content-type', content_type)], exc_info)

        # body
        return body