mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
Fix references to 'Request._request'
This commit is contained in:
parent
f457f3d906
commit
9bb17e4df6
|
@ -121,7 +121,7 @@ class SessionAuthentication(BaseAuthentication):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Get the session-based user from the underlying HttpRequest object
|
# Get the session-based user from the underlying HttpRequest object
|
||||||
user = getattr(request._request, 'user', None)
|
user = getattr(request.http_request, 'user', None)
|
||||||
|
|
||||||
# Unauthenticated, CSRF validation not required
|
# Unauthenticated, CSRF validation not required
|
||||||
if not user or not user.is_active:
|
if not user or not user.is_active:
|
||||||
|
|
|
@ -98,7 +98,7 @@ def clone_request(request, method):
|
||||||
Internal helper method to clone a request, replacing with a different
|
Internal helper method to clone a request, replacing with a different
|
||||||
HTTP method. Used for checking permissions against other methods.
|
HTTP method. Used for checking permissions against other methods.
|
||||||
"""
|
"""
|
||||||
ret = Request(request=request._request,
|
ret = Request(request=request.http_request,
|
||||||
parsers=request.parsers,
|
parsers=request.parsers,
|
||||||
authenticators=request.authenticators,
|
authenticators=request.authenticators,
|
||||||
negotiator=request.negotiator,
|
negotiator=request.negotiator,
|
||||||
|
@ -203,7 +203,7 @@ class Request(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def content_type(self):
|
def content_type(self):
|
||||||
meta = self._request.META
|
meta = self.http_request.META
|
||||||
return meta.get('CONTENT_TYPE', meta.get('HTTP_CONTENT_TYPE', ''))
|
return meta.get('CONTENT_TYPE', meta.get('HTTP_CONTENT_TYPE', ''))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -220,7 +220,7 @@ class Request(object):
|
||||||
"""
|
"""
|
||||||
More semantically correct name for request.GET.
|
More semantically correct name for request.GET.
|
||||||
"""
|
"""
|
||||||
return self._request.GET
|
return self.http_request.GET
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
@ -250,7 +250,7 @@ class Request(object):
|
||||||
instance, ensuring that it is available to any middleware in the stack.
|
instance, ensuring that it is available to any middleware in the stack.
|
||||||
"""
|
"""
|
||||||
self._user = value
|
self._user = value
|
||||||
self._request.user = value
|
self.http_request.user = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def auth(self):
|
def auth(self):
|
||||||
|
@ -270,7 +270,7 @@ class Request(object):
|
||||||
request, such as an authentication token.
|
request, such as an authentication token.
|
||||||
"""
|
"""
|
||||||
self._auth = value
|
self._auth = value
|
||||||
self._request.auth = value
|
self.http_request.auth = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def successful_authenticator(self):
|
def successful_authenticator(self):
|
||||||
|
@ -297,14 +297,14 @@ class Request(object):
|
||||||
|
|
||||||
# copy data & files refs to the underlying request so that closable
|
# copy data & files refs to the underlying request so that closable
|
||||||
# objects are handled appropriately.
|
# objects are handled appropriately.
|
||||||
self._request._post = self.POST
|
self.http_request._post = self.POST
|
||||||
self._request._files = self.FILES
|
self.http_request._files = self.FILES
|
||||||
|
|
||||||
def _load_stream(self):
|
def _load_stream(self):
|
||||||
"""
|
"""
|
||||||
Return the content body of the request, as a stream.
|
Return the content body of the request, as a stream.
|
||||||
"""
|
"""
|
||||||
meta = self._request.META
|
meta = self.http_request.META
|
||||||
try:
|
try:
|
||||||
content_length = int(
|
content_length = int(
|
||||||
meta.get('CONTENT_LENGTH', meta.get('HTTP_CONTENT_LENGTH', 0))
|
meta.get('CONTENT_LENGTH', meta.get('HTTP_CONTENT_LENGTH', 0))
|
||||||
|
@ -314,8 +314,8 @@ class Request(object):
|
||||||
|
|
||||||
if content_length == 0:
|
if content_length == 0:
|
||||||
self._stream = None
|
self._stream = None
|
||||||
elif not self._request._read_started:
|
elif not self.http_request._read_started:
|
||||||
self._stream = self._request
|
self._stream = self.http_request
|
||||||
else:
|
else:
|
||||||
self._stream = six.BytesIO(self.body)
|
self._stream = six.BytesIO(self.body)
|
||||||
|
|
||||||
|
@ -339,18 +339,18 @@ class Request(object):
|
||||||
try:
|
try:
|
||||||
stream = self.stream
|
stream = self.stream
|
||||||
except RawPostDataException:
|
except RawPostDataException:
|
||||||
if not hasattr(self._request, '_post'):
|
if not hasattr(self.http_request, '_post'):
|
||||||
raise
|
raise
|
||||||
# If request.POST has been accessed in middleware, and a method='POST'
|
# If request.POST has been accessed in middleware, and a method='POST'
|
||||||
# request was made with 'multipart/form-data', then the request stream
|
# request was made with 'multipart/form-data', then the request stream
|
||||||
# will already have been exhausted.
|
# will already have been exhausted.
|
||||||
if self._supports_form_parsing():
|
if self._supports_form_parsing():
|
||||||
return (self._request.POST, self._request.FILES)
|
return (self.http_request.POST, self.http_request.FILES)
|
||||||
stream = None
|
stream = None
|
||||||
|
|
||||||
if stream is None or media_type is None:
|
if stream is None or media_type is None:
|
||||||
if media_type and is_form_media_type(media_type):
|
if media_type and is_form_media_type(media_type):
|
||||||
empty_data = QueryDict('', encoding=self._request._encoding)
|
empty_data = QueryDict('', encoding=self.http_request._encoding)
|
||||||
else:
|
else:
|
||||||
empty_data = {}
|
empty_data = {}
|
||||||
empty_files = MultiValueDict()
|
empty_files = MultiValueDict()
|
||||||
|
@ -368,7 +368,7 @@ class Request(object):
|
||||||
# re-raise. Ensures we don't simply repeat the error when
|
# re-raise. Ensures we don't simply repeat the error when
|
||||||
# attempting to render the browsable renderer response, or when
|
# attempting to render the browsable renderer response, or when
|
||||||
# logging the request or similar.
|
# logging the request or similar.
|
||||||
self._data = QueryDict('', encoding=self._request._encoding)
|
self._data = QueryDict('', encoding=self.http_request._encoding)
|
||||||
self._files = MultiValueDict()
|
self._files = MultiValueDict()
|
||||||
self._full_data = self._data
|
self._full_data = self._data
|
||||||
raise
|
raise
|
||||||
|
@ -424,7 +424,7 @@ class Request(object):
|
||||||
to proxy it to the underlying HttpRequest object.
|
to proxy it to the underlying HttpRequest object.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return getattr(self._request, attr)
|
return getattr(self.http_request, attr)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return self.__getattribute__(attr)
|
return self.__getattribute__(attr)
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ class Request(object):
|
||||||
self._load_data_and_files()
|
self._load_data_and_files()
|
||||||
if is_form_media_type(self.content_type):
|
if is_form_media_type(self.content_type):
|
||||||
return self._data
|
return self._data
|
||||||
return QueryDict('', encoding=self._request._encoding)
|
return QueryDict('', encoding=self.http_request._encoding)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def FILES(self):
|
def FILES(self):
|
||||||
|
@ -463,4 +463,4 @@ class Request(object):
|
||||||
def force_plaintext_errors(self, value):
|
def force_plaintext_errors(self, value):
|
||||||
# Hack to allow our exception handler to force choice of
|
# Hack to allow our exception handler to force choice of
|
||||||
# plaintext or html error responses.
|
# plaintext or html error responses.
|
||||||
self._request.is_ajax = lambda: value
|
self.http_request.is_ajax = lambda: value
|
||||||
|
|
Loading…
Reference in New Issue
Block a user