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
740f63a3
Kaydet (Commit)
740f63a3
authored
8 years ago
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #26263 -- Removed deprecated Context.has_key().
üst
bcf3532e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
34 deletions
+3
-34
context.py
django/template/context.py
+0
-10
2.0.txt
docs/releases/2.0.txt
+2
-0
test_context.py
tests/template_tests/test_context.py
+1
-24
No files found.
django/template/context.py
Dosyayı görüntüle @
740f63a3
import
warnings
from
contextlib
import
contextmanager
from
copy
import
copy
from
django.utils.deprecation
import
RemovedInDjango20Warning
# Hard-coded processor for easier use of CSRF protection.
_builtin_context_processors
=
(
'django.template.context_processors.csrf'
,)
...
...
@@ -90,13 +87,6 @@ class BaseContext(object):
"Delete a variable from the current context"
del
self
.
dicts
[
-
1
][
key
]
def
has_key
(
self
,
key
):
warnings
.
warn
(
"
%
s.has_key() is deprecated in favor of the 'in' operator."
%
self
.
__class__
.
__name__
,
RemovedInDjango20Warning
)
return
key
in
self
def
__contains__
(
self
,
key
):
for
d
in
self
.
dicts
:
if
key
in
d
:
...
...
This diff is collapsed.
Click to expand it.
docs/releases/2.0.txt
Dosyayı görüntüle @
740f63a3
...
...
@@ -345,3 +345,5 @@ these features.
* ``CommaSeparatedIntegerField`` is removed, except for support in historical
migrations.
* The template ``Context.has_key()`` method is removed.
This diff is collapsed.
Click to expand it.
tests/template_tests/test_context.py
Dosyayı görüntüle @
740f63a3
# -*- coding: utf-8 -*-
import
warnings
from
django.http
import
HttpRequest
from
django.template
import
(
Context
,
Engine
,
RequestContext
,
Template
,
Variable
,
VariableDoesNotExist
,
)
from
django.template.context
import
RenderContext
from
django.test
import
RequestFactory
,
SimpleTestCase
,
ignore_warnings
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.test
import
RequestFactory
,
SimpleTestCase
class
ContextTests
(
SimpleTestCase
):
...
...
@@ -184,26 +181,6 @@ class ContextTests(SimpleTestCase):
"""
RequestContext
(
HttpRequest
())
.
new
()
.
new
()
@ignore_warnings
(
category
=
RemovedInDjango20Warning
)
def
test_has_key
(
self
):
a
=
Context
({
'a'
:
1
})
b
=
RequestContext
(
HttpRequest
(),
{
'a'
:
1
})
msg
=
"Context.has_key() is deprecated in favor of the 'in' operator."
msg2
=
"RequestContext.has_key() is deprecated in favor of the 'in' operator."
with
warnings
.
catch_warnings
(
record
=
True
)
as
warns
:
warnings
.
simplefilter
(
'always'
)
self
.
assertIs
(
a
.
has_key
(
'a'
),
True
)
self
.
assertIs
(
a
.
has_key
(
'b'
),
False
)
self
.
assertIs
(
b
.
has_key
(
'a'
),
True
)
self
.
assertIs
(
b
.
has_key
(
'b'
),
False
)
self
.
assertEqual
(
len
(
warns
),
4
)
self
.
assertEqual
(
str
(
warns
[
0
]
.
message
),
msg
)
self
.
assertEqual
(
str
(
warns
[
1
]
.
message
),
msg
)
self
.
assertEqual
(
str
(
warns
[
2
]
.
message
),
msg2
)
self
.
assertEqual
(
str
(
warns
[
3
]
.
message
),
msg2
)
def
test_set_upward
(
self
):
c
=
Context
({
'a'
:
1
})
c
.
set_upward
(
'a'
,
2
)
...
...
This diff is collapsed.
Click to expand it.
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