Ticket #9847: base.3.diff

File base.3.diff, 2.8 KB (added by vkryachko, 14 years ago)
  • django/conf/urls/defaults.py

    From 22b9ea197751f2d36e99e8a47c5fbfcca7d66f53 Mon Sep 17 00:00:00 2001
    From: Vladimir Kryachko <vladimir.kryachko@etvnet.com>
    Date: Wed, 14 Jul 2010 21:52:41 -0400
    Subject: [PATCH] FIx
    
    
    diff --git a/django/conf/urls/defaults.py b/django/conf/urls/defaults.py
    index 3ab8bab..ecc79ba 100644
    a b __all__ = ['handler404', 'handler500', 'include', 'patterns', 'url']  
    55
    66handler404 = 'django.views.defaults.page_not_found'
    77handler500 = 'django.views.defaults.server_error'
     8handler403 = 'django.views.defaults.server_error'
    89
    910def include(arg, namespace=None, app_name=None):
    1011    if isinstance(arg, tuple):
  • django/core/handlers/base.py

    diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py
    index b03c2fd..65f2fa4 100644
    a b class BaseHandler(object):  
    131131                        finally:
    132132                            receivers = signals.got_request_exception.send(sender=self.__class__, request=request)
    133133            except exceptions.PermissionDenied:
    134                 return http.HttpResponseForbidden('<h1>Permission denied</h1>')
     134                try:
     135                    callback, param_dict = resolver.resolve403()
     136                    return callback(request, **param_dict)
     137                except:
     138                    return http.HttpResponseForbidden('<h1>Permission denied</h1>')
    135139            except SystemExit:
    136140                # Allow sys.exit() to actually exit. See tickets #1023 and #4701
    137141                raise
  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index cad57a5..4f7e07e 100644
    a b class RegexURLResolver(object):  
    260260
    261261    def resolve500(self):
    262262        return self._resolve_special('500')
     263   
     264    def resolve403(self):
     265        return self._resolve_special('403')
    263266
    264267    def reverse(self, lookup_view, *args, **kwargs):
    265268        if args and kwargs:
  • django/views/defaults.py

    diff --git a/django/views/defaults.py b/django/views/defaults.py
    index 68b9ad6..1364f10 100644
    a b def server_error(request, template_name='500.html'):  
    2323    t = loader.get_template(template_name) # You need to create a 500.html template.
    2424    return http.HttpResponseServerError(t.render(Context({})))
    2525
     26def permission_denied(request, template_name='403.html'):
     27    t = loader.get_template(template_name) # You need to create a 403.html template.
     28    return http.HttpResponseForbidden(t.render(Context({'request_path': request.path})))
     29
    2630def shortcut(request, content_type_id, object_id):
    2731    # TODO: Remove this in Django 2.0.
    2832    # This is a legacy view that depends on the contenttypes framework.
Back to Top