mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
add _mutable class attribute to MultiValueDict, like QueryDict
This commit is contained in:
parent
3e84dfbd24
commit
5aafc222ad
@ -163,7 +163,7 @@ class MultiPartParser:
|
|||||||
|
|
||||||
# Create the data structures to be used later.
|
# Create the data structures to be used later.
|
||||||
self._post = QueryDict(mutable=True)
|
self._post = QueryDict(mutable=True)
|
||||||
self._files = MultiValueDict(mutable=True)
|
self._files = MultiValueDict()
|
||||||
|
|
||||||
# Instantiate the parser and stream:
|
# Instantiate the parser and stream:
|
||||||
stream = LazyStream(ChunkIter(self._input_data, self._chunk_size))
|
stream = LazyStream(ChunkIter(self._input_data, self._chunk_size))
|
||||||
|
@ -69,9 +69,11 @@ class MultiValueDict(dict):
|
|||||||
single name-value pairs.
|
single name-value pairs.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_mutable = True
|
||||||
|
|
||||||
def __init__(self, key_to_list_mapping=(), mutable=True):
|
def __init__(self, key_to_list_mapping=(), mutable=True):
|
||||||
self._mutable = mutable
|
|
||||||
super().__init__(key_to_list_mapping)
|
super().__init__(key_to_list_mapping)
|
||||||
|
self._mutable = mutable
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s: %s>" % (self.__class__.__name__, super().__repr__())
|
return "<%s: %s>" % (self.__class__.__name__, super().__repr__())
|
||||||
@ -117,7 +119,7 @@ class MultiValueDict(dict):
|
|||||||
self.__dict__.update(obj_dict)
|
self.__dict__.update(obj_dict)
|
||||||
|
|
||||||
def _assert_mutable(self):
|
def _assert_mutable(self):
|
||||||
if hasattr(self, '_mutable') and not self._mutable:
|
if not self._mutable:
|
||||||
raise AttributeError("This MultiValueDict instance is immutable")
|
raise AttributeError("This MultiValueDict instance is immutable")
|
||||||
|
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user