qmsk/irclogs/wsgi.py
changeset 140 6db2527b67cf
parent 135 19ff083c2870
equal deleted inserted replaced
139:9c7769850195 140:6db2527b67cf
       
     1 """
       
     2     Our custom WSGI application
       
     3 """
       
     4 
       
     5 from qmsk.web import wsgi
       
     6 
       
     7 import urls, error
       
     8 
       
     9 # our custom app with custom error() method
       
    10 class Application (wsgi.Application) :
       
    11     def __init__ (self) :
       
    12         """
       
    13             Construct wsgi.Application with our URLMapper
       
    14         """
       
    15 
       
    16         super(Application, self).__init__(urls.mapper)
       
    17     
       
    18     def handle_error (self, exc_info, env, start_response) :
       
    19         """
       
    20             Use error.build_error and return that
       
    21         """
       
    22         
       
    23         # get info
       
    24         status, content_type, body = error.build_error(env=env)
       
    25 
       
    26         # headers
       
    27         start_response(status, [('Content-type', content_type)], exc_info)
       
    28 
       
    29         # body
       
    30         return body
       
    31