python-oxdjango/oxdjango/middleware.py

16 lines
511 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
2010-02-08 16:07:32 +00:00
from shortcuts import HttpErrorJson, render_to_json_response
class ExceptionMiddleware(object):
def process_exception(self, request, exception):
2010-02-08 16:07:32 +00:00
if isinstance(exception, HttpErrorJson):
return render_to_json_response(exception.response)
2010-02-09 06:50:59 +00:00
return None
2010-09-27 15:47:54 +00:00
class ChromeFrameMiddleware(object):
def process_response(self, request, response):
response['X-UA-Compatible'] = 'chrome=1'
return response