@@ -0,0 +1,1726 @@
+#!/usr/bin/python2.5%0A#%0A# Copyright 2009 the Melange authors.%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#   http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0A%22%22%22Middleware to handle exceptions.%0A%22%22%22%0A%0A__authors__ = %5B%0A  '%22Sverre Rabbelier%22 %3Csverre@rabbelier.nl%3E',%0A  %5D%0A%0A%0Aimport logging%0A%0Afrom google.appengine.runtime import DeadlineExceededError%0Afrom google.appengine.runtime.apiproxy_errors import CapabilityDisabledError%0A%0Afrom django import http%0A%0Afrom soc.views.helper import responses%0Afrom soc.views import out_of_band%0A%0A%0Aclass ExceptionHandlerMiddleware(object):%0A  %22%22%22Middleware class to handle exceptions..%0A  %22%22%22%0A%0A  def process_exception(self, request, exception):%0A    template = None%0A    context = responses.getUniversalContext(request)%0A%0A    if isinstance(exception, DeadlineExceededError):%0A      template = 'soc/deadline_exceeded.html'%0A    if isinstance(exception, MemoryError):%0A      template = 'soc/memory_error.html'%0A    if isinstance(exception, AssertionError):%0A      template = 'soc/assertion_error.html'%0A    if isinstance(exception, out_of_band.Error):%0A      return responses.errorResponse(error, request)%0A%0A    if template:%0A      logging.exception(exception)%0A      return responses.respond(request, template, context=context)%0A%0A    # let Django handle it%0A    return None%0A

Add ExceptionHandlerMiddleware