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
f88ad710
Kaydet (Commit)
f88ad710
authored
Kas 18, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Simplified caching of template context processors.
üst
a97e72aa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
23 deletions
+14
-23
context.py
django/template/context.py
+7
-16
signals.py
django/test/signals.py
+2
-2
context_processors.py
tests/test_client_regress/context_processors.py
+2
-0
tests.py
tests/test_client_regress/tests.py
+3
-5
No files found.
django/template/context.py
Dosyayı görüntüle @
f88ad710
from
copy
import
copy
from
django.conf
import
settings
from
django.utils
import
lru_cache
from
django.utils.module_loading
import
import_string
# Cache of actual callables.
_standard_context_processors
=
None
# Hard-coded processor for easier use of CSRF protection.
_builtin_context_processors
=
(
'django.core.context_processors.csrf'
,)
...
...
@@ -170,21 +171,11 @@ class RenderContext(BaseContext):
return
self
.
dicts
[
-
1
][
key
]
# This is a function rather than module-level procedural code because we only
# want it to execute if somebody uses RequestContext.
@lru_cache.lru_cache
()
def
get_standard_processors
():
from
django.conf
import
settings
global
_standard_context_processors
if
_standard_context_processors
is
None
:
processors
=
[]
collect
=
[]
collect
.
extend
(
_builtin_context_processors
)
collect
.
extend
(
settings
.
TEMPLATE_CONTEXT_PROCESSORS
)
for
path
in
collect
:
func
=
import_string
(
path
)
processors
.
append
(
func
)
_standard_context_processors
=
tuple
(
processors
)
return
_standard_context_processors
context_processors
=
_builtin_context_processors
context_processors
+=
tuple
(
settings
.
TEMPLATE_CONTEXT_PROCESSORS
)
return
tuple
(
import_string
(
path
)
for
path
in
context_processors
)
class
RequestContext
(
Context
):
...
...
django/test/signals.py
Dosyayı görüntüle @
f88ad710
...
...
@@ -80,8 +80,8 @@ def update_connections_time_zone(**kwargs):
@receiver
(
setting_changed
)
def
clear_context_processors_cache
(
**
kwargs
):
if
kwargs
[
'setting'
]
==
'TEMPLATE_CONTEXT_PROCESSORS'
:
from
django.template
import
context
context
.
_standard_context_processors
=
None
from
django.template
.context
import
get_standard_processors
get_standard_processors
.
cache_clear
()
@receiver
(
setting_changed
)
...
...
tests/test_client_regress/context_processors.py
0 → 100644
Dosyayı görüntüle @
f88ad710
def
special
(
request
):
return
{
'path'
:
request
.
special_path
}
tests/test_client_regress/tests.py
Dosyayı görüntüle @
f88ad710
...
...
@@ -9,7 +9,6 @@ import itertools
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
django.template
import
TemplateSyntaxError
,
Context
,
Template
import
django.template.context
from
django.test
import
Client
,
TestCase
,
override_settings
from
django.test.client
import
encode_file
,
RequestFactory
from
django.test.utils
import
ContextList
,
str_prefix
...
...
@@ -994,12 +993,11 @@ class ContextTests(TestCase):
# Need to insert a context processor that assumes certain things about
# the request instance. This triggers a bug caused by some ways of
# copying RequestContext.
try
:
django
.
template
.
context
.
_standard_context_processors
=
(
lambda
request
:
{
'path'
:
request
.
special_path
},)
with
self
.
settings
(
TEMPLATE_CONTEXT_PROCESSORS
=
(
'test_client_regress.context_processors.special'
,
)):
response
=
self
.
client
.
get
(
"/request_context_view/"
)
self
.
assertContains
(
response
,
'Path: /request_context_view/'
)
finally
:
django
.
template
.
context
.
_standard_context_processors
=
None
def
test_nested_requests
(
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