bug fix: removed \r in textversion's content because of a comment position bug in pre_edit. Added a save function to TextVersionManager to do so. Also removed cleaning \r before computing diffs because it should not be necessary anymore.
from cm.exception import UnauthorizedException
from django.conf import settings
from django.http import HttpResponseServerError,HttpResponseRedirect
from django.core.urlresolvers import reverse
class CmMiddleware(object):
def process_exception(self, request, exception):
if settings.DEBUG:
import sys, traceback
traceback.print_exc()
if type(exception) == UnauthorizedException:
if request.user.is_anonymous():
login_url = reverse('login') + '?next=%s' %request.META['PATH_INFO']
return HttpResponseRedirect(login_url)
else:
redirect_url = reverse('unauthorized')
return HttpResponseRedirect(redirect_url)
raise