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
75f107b8
Kaydet (Commit)
75f107b8
authored
Kas 18, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed request.REQUEST per deprecation timeline; refs #18659.
üst
61ad1ea9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
6 additions
and
74 deletions
+6
-74
wsgi.py
django/core/handlers/wsgi.py
+0
-11
request-response.txt
docs/ref/request-response.txt
+0
-15
middleware.txt
docs/topics/http/middleware.txt
+5
-6
tests.py
tests/deprecation/tests.py
+1
-21
tests.py
tests/test_client_regress/tests.py
+0
-15
views.py
tests/test_client_regress/views.py
+0
-6
No files found.
django/core/handlers/wsgi.py
Dosyayı görüntüle @
75f107b8
...
...
@@ -6,15 +6,12 @@ import logging
import
sys
from
io
import
BytesIO
from
threading
import
Lock
import
warnings
from
django
import
http
from
django.conf
import
settings
from
django.core
import
signals
from
django.core.handlers
import
base
from
django.core.urlresolvers
import
set_script_prefix
from
django.utils
import
datastructures
from
django.utils.deprecation
import
RemovedInDjango19Warning
from
django.utils.encoding
import
force_str
,
force_text
from
django.utils.functional
import
cached_property
from
django.utils
import
six
...
...
@@ -121,13 +118,6 @@ class WSGIRequest(http.HttpRequest):
def
_get_scheme
(
self
):
return
self
.
environ
.
get
(
'wsgi.url_scheme'
)
def
_get_request
(
self
):
warnings
.
warn
(
'`request.REQUEST` is deprecated, use `request.GET` or '
'`request.POST` instead.'
,
RemovedInDjango19Warning
,
2
)
if
not
hasattr
(
self
,
'_request'
):
self
.
_request
=
datastructures
.
MergeDict
(
self
.
POST
,
self
.
GET
)
return
self
.
_request
@cached_property
def
GET
(
self
):
# The WSGI spec says 'QUERY_STRING' may be absent.
...
...
@@ -154,7 +144,6 @@ class WSGIRequest(http.HttpRequest):
POST
=
property
(
_get_post
,
_set_post
)
FILES
=
property
(
_get_files
)
REQUEST
=
property
(
_get_request
)
class
WSGIHandler
(
base
.
BaseHandler
):
...
...
docs/ref/request-response.txt
Dosyayı görüntüle @
75f107b8
...
...
@@ -108,21 +108,6 @@ All attributes should be considered read-only, unless stated otherwise below.
Note: ``POST`` does *not* include file-upload information. See ``FILES``.
.. attribute:: HttpRequest.REQUEST
.. deprecated:: 1.7
Use the more explicit ``GET`` and ``POST`` instead.
For convenience, a dictionary-like object that searches ``POST`` first,
then ``GET``. Inspired by PHP's ``$_REQUEST``.
For example, if ``GET = {"name": "john"}`` and ``POST = {"age": '34'}``,
``REQUEST["name"]`` would be ``"john"``, and ``REQUEST["age"]`` would be
``"34"``.
It's strongly suggested that you use ``GET`` and ``POST`` instead of
``REQUEST``, because the former are more explicit.
.. attribute:: HttpRequest.COOKIES
A standard Python dictionary containing all cookies. Keys and values are
...
...
docs/topics/http/middleware.txt
Dosyayı görüntüle @
75f107b8
...
...
@@ -130,12 +130,11 @@ view; it'll apply response middleware to that
.. note::
Accessing :attr:`request.POST <django.http.HttpRequest.POST>` or
:attr:`request.REQUEST <django.http.HttpRequest.REQUEST>` inside middleware
from ``process_request`` or ``process_view`` will prevent any view running
after the middleware from being able to :ref:`modify the upload handlers
for the request <modifying_upload_handlers_on_the_fly>`, and should
normally be avoided.
Accessing :attr:`request.POST <django.http.HttpRequest.POST>` inside
middleware from ``process_request`` or ``process_view`` will prevent any
view running after the middleware from being able to :ref:`modify the
upload handlers for the request <modifying_upload_handlers_on_the_fly>`,
and should normally be avoided.
The :class:`~django.middleware.csrf.CsrfViewMiddleware` class can be
considered an exception, as it provides the
...
...
tests/deprecation/tests.py
Dosyayı görüntüle @
75f107b8
...
...
@@ -4,7 +4,7 @@ import os
import
unittest
import
warnings
from
django.test
import
SimpleTestCase
,
RequestFactory
,
override_settings
from
django.test
import
SimpleTestCase
,
override_settings
from
django.test.utils
import
reset_warning_registry
from
django.utils
import
six
,
translation
from
django.utils.deprecation
import
RenameMethodsBase
...
...
@@ -175,26 +175,6 @@ class RenameMethodsTests(SimpleTestCase):
])
class
DeprecatingRequestMergeDictTest
(
SimpleTestCase
):
def
test_deprecated_request
(
self
):
"""
Ensure the correct warning is raised when WSGIRequest.REQUEST is
accessed.
"""
reset_warning_registry
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
warnings
.
simplefilter
(
'always'
)
request
=
RequestFactory
()
.
get
(
'/'
)
request
.
REQUEST
# evaluate
msgs
=
[
str
(
warning
.
message
)
for
warning
in
recorded
]
self
.
assertEqual
(
msgs
,
[
'`request.REQUEST` is deprecated, use `request.GET` or '
'`request.POST` instead.'
,
'`MergeDict` is deprecated, use `dict.update()` instead.'
,
])
@override_settings
(
USE_I18N
=
True
)
class
DeprecatedChineseLanguageCodes
(
SimpleTestCase
):
def
test_deprecation_warning
(
self
):
...
...
tests/test_client_regress/tests.py
Dosyayı görüntüle @
75f107b8
...
...
@@ -953,14 +953,12 @@ class zzUrlconfSubstitutionTests(TestCase):
class
ContextTests
(
TestCase
):
fixtures
=
[
'testdata'
]
@ignore_warnings
(
category
=
RemovedInDjango19Warning
)
# `request.REQUEST` is deprecated
def
test_single_context
(
self
):
"Context variables can be retrieved from a single context"
response
=
self
.
client
.
get
(
"/request_data/"
,
data
=
{
'foo'
:
'whiz'
})
self
.
assertEqual
(
response
.
context
.
__class__
,
Context
)
self
.
assertIn
(
'get-foo'
,
response
.
context
)
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'data'
],
'sausage'
)
try
:
...
...
@@ -969,7 +967,6 @@ class ContextTests(TestCase):
except
KeyError
as
e
:
self
.
assertEqual
(
e
.
args
[
0
],
'does-not-exist'
)
@ignore_warnings
(
category
=
RemovedInDjango19Warning
)
# `request.REQUEST` is deprecated
def
test_inherited_context
(
self
):
"Context variables can be retrieved from a list of contexts"
response
=
self
.
client
.
get
(
"/request_data_extended/"
,
data
=
{
'foo'
:
'whiz'
})
...
...
@@ -977,7 +974,6 @@ class ContextTests(TestCase):
self
.
assertEqual
(
len
(
response
.
context
),
2
)
self
.
assertIn
(
'get-foo'
,
response
.
context
)
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'data'
],
'bacon'
)
try
:
...
...
@@ -1252,7 +1248,6 @@ class RequestMethodStringDataTests(TestCase):
@override_settings
(
ROOT_URLCONF
=
'test_client_regress.urls'
,)
class
QueryStringTests
(
TestCase
):
@ignore_warnings
(
category
=
RemovedInDjango19Warning
)
# `request.REQUEST` is deprecated
def
test_get_like_requests
(
self
):
# See: https://code.djangoproject.com/ticket/10571.
for
method_name
in
(
'get'
,
'head'
):
...
...
@@ -1260,25 +1255,19 @@ class QueryStringTests(TestCase):
method
=
getattr
(
self
.
client
,
method_name
)
response
=
method
(
"/request_data/"
,
data
=
{
'foo'
:
'whiz'
})
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'whiz'
)
# A GET-like request can pass a query string as part of the URL
response
=
method
(
"/request_data/?foo=whiz"
)
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'whiz'
)
# Data provided in the URL to a GET-like request is overridden by actual form data
response
=
method
(
"/request_data/?foo=whiz"
,
data
=
{
'foo'
:
'bang'
})
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'bang'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'bang'
)
response
=
method
(
"/request_data/?foo=whiz"
,
data
=
{
'bar'
:
'bang'
})
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
None
)
self
.
assertEqual
(
response
.
context
[
'get-bar'
],
'bang'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
None
)
self
.
assertEqual
(
response
.
context
[
'request-bar'
],
'bang'
)
@ignore_warnings
(
category
=
RemovedInDjango19Warning
)
# `request.REQUEST` is deprecated
def
test_post_like_requests
(
self
):
# A POST-like request can pass a query string as data
response
=
self
.
client
.
post
(
"/request_data/"
,
data
=
{
'foo'
:
'whiz'
})
...
...
@@ -1289,21 +1278,17 @@ class QueryStringTests(TestCase):
response
=
self
.
client
.
post
(
"/request_data/?foo=whiz"
)
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'post-foo'
],
None
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'whiz'
)
# POST data provided in the URL augments actual form data
response
=
self
.
client
.
post
(
"/request_data/?foo=whiz"
,
data
=
{
'foo'
:
'bang'
})
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'post-foo'
],
'bang'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'bang'
)
response
=
self
.
client
.
post
(
"/request_data/?foo=whiz"
,
data
=
{
'bar'
:
'bang'
})
self
.
assertEqual
(
response
.
context
[
'get-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'get-bar'
],
None
)
self
.
assertEqual
(
response
.
context
[
'post-foo'
],
None
)
self
.
assertEqual
(
response
.
context
[
'post-bar'
],
'bang'
)
self
.
assertEqual
(
response
.
context
[
'request-foo'
],
'whiz'
)
self
.
assertEqual
(
response
.
context
[
'request-bar'
],
'bang'
)
@override_settings
(
ROOT_URLCONF
=
'test_client_regress.urls'
)
...
...
tests/test_client_regress/views.py
Dosyayı görüntüle @
75f107b8
...
...
@@ -38,17 +38,11 @@ get_view = login_required(get_view)
def
request_data
(
request
,
template
=
'base.html'
,
data
=
'sausage'
):
"A simple view that returns the request data in the context"
request_foo
=
request
.
REQUEST
.
get
(
'foo'
)
request_bar
=
request
.
REQUEST
.
get
(
'bar'
)
return
render_to_response
(
template
,
{
'get-foo'
:
request
.
GET
.
get
(
'foo'
),
'get-bar'
:
request
.
GET
.
get
(
'bar'
),
'post-foo'
:
request
.
POST
.
get
(
'foo'
),
'post-bar'
:
request
.
POST
.
get
(
'bar'
),
'request-foo'
:
request_foo
,
'request-bar'
:
request_bar
,
'data'
:
data
,
})
...
...
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