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
0b4d5172
Kaydet (Commit)
0b4d5172
authored
Ara 14, 2016
tarafından
Preston Timmons
Kaydeden (comit)
Tim Graham
Ara 20, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27584 -- Fixed display of render time template errors.
üst
5e239ae9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
5 deletions
+45
-5
base.py
django/template/base.py
+2
-5
context.py
django/template/context.py
+13
-0
27584_child.html
tests/template_tests/templates/27584_child.html
+3
-0
27584_parent.html
tests/template_tests/templates/27584_parent.html
+1
-0
tag_27584.py
tests/template_tests/templatetags/tag_27584.py
+15
-0
tests.py
tests/template_tests/tests.py
+11
-0
No files found.
django/template/base.py
Dosyayı görüntüle @
0b4d5172
...
...
@@ -200,16 +200,13 @@ class Template(object):
def
render
(
self
,
context
):
"Display stage -- can be called many times"
context
.
render_context
.
push
()
try
:
with
context
.
render_context
.
push_state
(
self
):
if
context
.
template
is
None
:
with
context
.
bind_template
(
self
):
context
.
template_name
=
self
.
name
return
self
.
_render
(
context
)
else
:
return
self
.
_render
(
context
)
finally
:
context
.
render_context
.
pop
()
def
compile_nodelist
(
self
):
"""
...
...
@@ -960,7 +957,7 @@ class Node(object):
return
self
.
render
(
context
)
except
Exception
as
e
:
if
context
.
template
.
engine
.
debug
and
not
hasattr
(
e
,
'template_debug'
):
e
.
template_debug
=
context
.
template
.
get_exception_info
(
e
,
self
.
token
)
e
.
template_debug
=
context
.
render_context
.
template
.
get_exception_info
(
e
,
self
.
token
)
raise
def
__iter__
(
self
):
...
...
django/template/context.py
Dosyayı görüntüle @
0b4d5172
...
...
@@ -199,6 +199,8 @@ class RenderContext(BaseContext):
rendering of other templates as they would if they were stored in the normal
template context.
"""
template
=
None
def
__iter__
(
self
):
for
d
in
self
.
dicts
[
-
1
]:
yield
d
...
...
@@ -212,6 +214,17 @@ class RenderContext(BaseContext):
def
__getitem__
(
self
,
key
):
return
self
.
dicts
[
-
1
][
key
]
@contextmanager
def
push_state
(
self
,
template
):
initial
=
self
.
template
self
.
template
=
template
self
.
push
()
try
:
yield
finally
:
self
.
template
=
initial
self
.
pop
()
class
RequestContext
(
Context
):
"""
...
...
tests/template_tests/templates/27584_child.html
0 → 100644
Dosyayı görüntüle @
0b4d5172
{% load tag_27584 %}
{% badtag %}{% endbadtag %}
tests/template_tests/templates/27584_parent.html
0 → 100644
Dosyayı görüntüle @
0b4d5172
{% include "27584_child.html" %}
tests/template_tests/templatetags/tag_27584.py
0 → 100644
Dosyayı görüntüle @
0b4d5172
from
django
import
template
register
=
template
.
Library
()
@register.tag
def
badtag
(
parser
,
token
):
parser
.
parse
((
'endbadtag'
,))
parser
.
delete_first_token
()
return
BadNode
()
class
BadNode
(
template
.
Node
):
def
render
(
self
,
context
):
raise
template
.
TemplateSyntaxError
(
'error'
)
tests/template_tests/tests.py
Dosyayı görüntüle @
0b4d5172
...
...
@@ -114,6 +114,17 @@ class TemplateTests(SimpleTestCase):
engine
.
from_string
(
"{
%
load bad_tag
%
}{
%
badtag
%
}"
)
self
.
assertEqual
(
e
.
exception
.
template_debug
[
'during'
],
'{
%
badtag
%
}'
)
def
test_compile_tag_error_27584
(
self
):
engine
=
Engine
(
app_dirs
=
True
,
debug
=
True
,
libraries
=
{
'tag_27584'
:
'template_tests.templatetags.tag_27584'
},
)
t
=
engine
.
get_template
(
'27584_parent.html'
)
with
self
.
assertRaises
(
TemplateSyntaxError
)
as
e
:
t
.
render
(
Context
())
self
.
assertEqual
(
e
.
exception
.
template_debug
[
'during'
],
'{
%
badtag
%
}'
)
def
test_super_errors
(
self
):
"""
#18169 -- NoReverseMatch should not be silence in block.super.
...
...
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