Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
742ea514
Kaydet (Commit)
742ea514
authored
Haz 23, 2016
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #24829 -- Made TemplateResponse.content available sooner in exception context
Thanks Tim Graham for the initial patch.
üst
9f663027
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
exception.py
django/core/handlers/exception.py
+4
-0
tests_custom_error_handlers.py
tests/handlers/tests_custom_error_handlers.py
+14
-1
No files found.
django/core/handlers/exception.py
Dosyayı görüntüle @
742ea514
...
...
@@ -85,6 +85,10 @@ def response_for_exception(request, exc):
signals
.
got_request_exception
.
send
(
sender
=
None
,
request
=
request
)
response
=
handle_uncaught_exception
(
request
,
get_resolver
(
get_urlconf
()),
sys
.
exc_info
())
# Force a TemplateResponse to be rendered.
if
not
getattr
(
response
,
'is_rendered'
,
True
)
and
callable
(
getattr
(
response
,
'render'
,
None
)):
response
=
response
.
render
()
return
response
...
...
tests/handlers/tests_custom_error_handlers.py
Dosyayı görüntüle @
742ea514
from
django.conf.urls
import
url
from
django.core.exceptions
import
PermissionDenied
from
django.template.response
import
TemplateResponse
from
django.test
import
SimpleTestCase
,
override_settings
from
django.test
import
SimpleTestCase
,
modify_settings
,
override_settings
class
MiddlewareAccessingContent
(
object
):
def
__init__
(
self
,
get_response
):
self
.
get_response
=
get_response
def
__call__
(
self
,
request
):
response
=
self
.
get_response
(
request
)
# Response.content should be available in the middleware even with a
# TemplateResponse-based exception response.
assert
response
.
content
return
response
def
template_response_error_handler
(
request
,
exception
=
None
):
...
...
@@ -20,6 +32,7 @@ handler403 = template_response_error_handler
@override_settings
(
ROOT_URLCONF
=
'handlers.tests_custom_error_handlers'
)
@modify_settings
(
MIDDLEWARE
=
{
'append'
:
'handlers.tests_custom_error_handlers.MiddlewareAccessingContent'
})
class
CustomErrorHandlerTests
(
SimpleTestCase
):
def
test_handler_renders_template_response
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment