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
85c52743
Kaydet (Commit)
85c52743
authored
Eyl 21, 2015
tarafından
Nick Johnson
Kaydeden (comit)
Tim Graham
Eyl 21, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #18773 -- Improved template variable exception logging message.
üst
4b1416d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
base.py
django/template/base.py
+7
-2
test_logging.py
tests/template_tests/test_logging.py
+15
-6
No files found.
django/template/base.py
Dosyayı görüntüle @
85c52743
...
...
@@ -902,8 +902,13 @@ class Variable(object):
else
:
raise
except
Exception
as
e
:
template_name
=
getattr
(
context
,
'template_name'
,
'unknown'
)
logger
.
debug
(
'{} - {}'
.
format
(
template_name
,
e
))
template_name
=
getattr
(
context
,
'template_name'
,
None
)
or
'unknown'
logger
.
debug
(
"Exception while resolving variable '
%
s' in template '
%
s'."
,
bit
,
template_name
,
exc_info
=
True
,
)
if
getattr
(
e
,
'silent_variable_failure'
,
False
):
current
=
context
.
template
.
engine
.
string_if_invalid
...
...
tests/template_tests/test_logging.py
Dosyayı görüntüle @
85c52743
...
...
@@ -34,7 +34,7 @@ class VariableResolveLoggingTests(SimpleTestCase):
@property
def
template_name
(
self
):
return
"template"
return
"template
_name
"
@property
def
template
(
self
):
...
...
@@ -51,19 +51,28 @@ class VariableResolveLoggingTests(SimpleTestCase):
return
self
.
__dict__
[
item
]
Variable
(
'article'
)
.
resolve
(
TestObject
())
self
.
assertEqual
(
self
.
test_handler
.
log_record
.
msg
,
'template - Attribute does not exist.'
self
.
test_handler
.
log_record
.
getMessage
()
,
"Exception while resolving variable 'article' in template 'template_name'."
)
self
.
assertIsNotNone
(
self
.
test_handler
.
log_record
.
exc_info
)
raised_exception
=
self
.
test_handler
.
log_record
.
exc_info
[
1
]
self
.
assertEqual
(
str
(
raised_exception
),
'Attribute does not exist.'
)
def
test_log_on_variable_does_not_exist_not_silent
(
self
):
with
self
.
assertRaises
(
VariableDoesNotExist
):
Variable
(
'article.author'
)
.
resolve
({
'article'
:
{
'section'
:
'News'
}})
self
.
assertEqual
(
self
.
test_handler
.
log_record
.
msg
,
'unknown - Failed lookup for key [author] in
%
r'
%
(
"{
%
r:
%
r}"
%
(
'section'
,
'News'
),
)
self
.
test_handler
.
log_record
.
getMessage
(),
"Exception while resolving variable 'author' in template 'unknown'."
)
self
.
assertIsNotNone
(
self
.
test_handler
.
log_record
.
exc_info
)
raised_exception
=
self
.
test_handler
.
log_record
.
exc_info
[
1
]
self
.
assertEqual
(
str
(
raised_exception
),
'Failed lookup for key [author] in
%
r'
%
(
"{
%
r:
%
r}"
%
(
'section'
,
'News'
))
)
def
test_no_log_when_variable_exists
(
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