mirror of
https://github.com/django/django.git
synced 2025-03-13 10:50:55 +00:00
Refs #33396 -- Added django.views.debug.get_caller() hook.
This commit is contained in:
parent
90cf963264
commit
4099e6e737
@ -85,6 +85,16 @@ def get_exception_reporter_class(request):
|
|||||||
return getattr(request, 'exception_reporter_class', default_exception_reporter_class)
|
return getattr(request, 'exception_reporter_class', default_exception_reporter_class)
|
||||||
|
|
||||||
|
|
||||||
|
def get_caller(request):
|
||||||
|
resolver_match = request.resolver_match
|
||||||
|
if resolver_match is None:
|
||||||
|
try:
|
||||||
|
resolver_match = resolve(request.path)
|
||||||
|
except Http404:
|
||||||
|
pass
|
||||||
|
return '' if resolver_match is None else resolver_match._func_path
|
||||||
|
|
||||||
|
|
||||||
class SafeExceptionReporterFilter:
|
class SafeExceptionReporterFilter:
|
||||||
"""
|
"""
|
||||||
Use annotations made by the sensitive_post_parameters and
|
Use annotations made by the sensitive_post_parameters and
|
||||||
@ -536,13 +546,6 @@ def technical_404_response(request, exception):
|
|||||||
if isinstance(urlconf, types.ModuleType):
|
if isinstance(urlconf, types.ModuleType):
|
||||||
urlconf = urlconf.__name__
|
urlconf = urlconf.__name__
|
||||||
|
|
||||||
resolver_match = request.resolver_match
|
|
||||||
if resolver_match is None:
|
|
||||||
try:
|
|
||||||
resolver_match = resolve(request.path)
|
|
||||||
except Http404:
|
|
||||||
pass
|
|
||||||
|
|
||||||
with builtin_template_path('technical_404.html').open(encoding='utf-8') as fh:
|
with builtin_template_path('technical_404.html').open(encoding='utf-8') as fh:
|
||||||
t = DEBUG_ENGINE.from_string(fh.read())
|
t = DEBUG_ENGINE.from_string(fh.read())
|
||||||
reporter_filter = get_default_exception_reporter_filter()
|
reporter_filter = get_default_exception_reporter_filter()
|
||||||
@ -555,7 +558,7 @@ def technical_404_response(request, exception):
|
|||||||
'reason': str(exception),
|
'reason': str(exception),
|
||||||
'request': request,
|
'request': request,
|
||||||
'settings': reporter_filter.get_safe_settings(),
|
'settings': reporter_filter.get_safe_settings(),
|
||||||
'raising_view_name': '' if resolver_match is None else resolver_match._func_path,
|
'raising_view_name': get_caller(request),
|
||||||
})
|
})
|
||||||
return HttpResponseNotFound(t.render(c), content_type='text/html')
|
return HttpResponseNotFound(t.render(c), content_type='text/html')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user