from cgi import escape
try:
from functools import wraps
except ImportError:
# < 2.5
from repoze.bfg.functional import wraps
def wsgiapp(wrapped):
""" Decorator to turn a WSGI application into a repoze.bfg view callable.
E.g.::
@wsgiapp
def hello_world(environ, start_response):
body = 'Hello world'
start_response('200 OK', [ ('Content-Type', 'text/plain'),
('Content-Length', len(body)) ] )
return [body]
Allows the following view declaration to be made::
%s
""" % (self.status, self.status, msg)
headers = [('Content-Length', len(html)), ('Content-Type', 'text/html')]
start_response(self.status, headers)
return [html]
class NotFound(HTTPException):
""" The default NotFound WSGI application """
status = '404 Not Found'
class Unauthorized(HTTPException):
""" The default Unauthorized WSGI application """
status = '401 Unauthorized'