multidictviews should not be serializable

This commit is contained in:
Maximilian Hils 2017-03-14 02:20:24 +01:00
parent de1de3f626
commit 30fd285ec7

View File

@ -4,7 +4,7 @@ from collections.abc import MutableMapping
from mitmproxy.types import serializable from mitmproxy.types import serializable
class _MultiDict(MutableMapping, serializable.Serializable, metaclass=ABCMeta): class _MultiDict(MutableMapping, metaclass=ABCMeta):
def __repr__(self): def __repr__(self):
fields = ( fields = (
repr(field) repr(field)
@ -174,18 +174,8 @@ class _MultiDict(MutableMapping, serializable.Serializable, metaclass=ABCMeta):
coll.append([key, values]) coll.append([key, values])
return coll return coll
def get_state(self):
return self.fields
def set_state(self, state): class MultiDict(_MultiDict, serializable.Serializable):
self.fields = tuple(tuple(x) for x in state)
@classmethod
def from_state(cls, state):
return cls(state)
class MultiDict(_MultiDict):
def __init__(self, fields=()): def __init__(self, fields=()):
super().__init__() super().__init__()
self.fields = tuple( self.fields = tuple(
@ -200,6 +190,16 @@ class MultiDict(_MultiDict):
def _kconv(key): def _kconv(key):
return key return key
def get_state(self):
return self.fields
def set_state(self, state):
self.fields = tuple(tuple(x) for x in state)
@classmethod
def from_state(cls, state):
return cls(state)
class MultiDictView(_MultiDict): class MultiDictView(_MultiDict):
""" """