Permalink
Browse files

fixed bugs with middleware and bumped version number

  • Loading branch information...
1 parent 16bfefd commit 12b8f5c48107b0ca0cf77cad92b31ce03a95dce3 @andrewschoen andrewschoen committed Apr 13, 2011
Showing with 3 additions and 29 deletions.
  1. +2 −2 cms_redirects/__init__.py
  2. +1 −27 cms_redirects/middleware.py
@@ -1,2 +1,2 @@
-VERSION = (1,0,0)
-__version__ = "1.0.0"
+VERSION = (1,0,1)
+__version__ = "1.0.1"
@@ -3,34 +3,8 @@
from django.conf import settings
class RedirectFallbackMiddleware(object):
- """
- def process_response(self, request, response):
- if response.status_code != 404:
- return response # No need to check for a redirect for non-404 responses.
- path = request.get_full_path()
- try:
- r = CMSRedirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)
- except CMSRedirect.DoesNotExist:
- r = None
- if r is None and settings.APPEND_SLASH:
- # Try removing the trailing slash.
- try:
- r = CMSRedirect.objects.get(site__id__exact=settings.SITE_ID,
- old_path=path[:path.rfind('/')]+path[path.rfind('/')+1:])
- except CMSRedirect.DoesNotExist:
- pass
- if r is not None:
- if r.page:
- return http.HttpResponsePermanentRedirect(r.page.get_absolute_url())
- if r.new_path == '':
- return http.HttpResponseGone()
- return http.HttpResponsePermanentRedirect(r.new_path)
-
- # No redirect was found. Return the response.
- return response
- """
def process_exception(self, request, exception):
- if isinstance(exception, Http404):
+ if isinstance(exception, http.Http404):
path = request.get_full_path()
try:
r = CMSRedirect.objects.get(site__id__exact=settings.SITE_ID, old_path=path)

0 comments on commit 12b8f5c

Please sign in to comment.