equal
deleted
inserted
replaced
59 |
59 |
60 class MultiDict(DictMixin): |
60 class MultiDict(DictMixin): |
61 """ A dict that remembers old values for each key """ |
61 """ A dict that remembers old values for each key """ |
62 def __init__(self, *a, **k): |
62 def __init__(self, *a, **k): |
63 self.dict = dict() |
63 self.dict = dict() |
64 for k, v in dict(*a, **k).iteritems(): |
64 for k, v in dict(*a, **k).items(): |
65 self[k] = v |
65 self[k] = v |
66 |
66 |
67 def __len__(self): return len(self.dict) |
67 def __len__(self): return len(self.dict) |
68 def __iter__(self): return iter(self.dict) |
68 def __iter__(self): return iter(self.dict) |
69 def __contains__(self, key): return key in self.dict |
69 def __contains__(self, key): return key in self.dict |
80 if key not in self.dict and default != KeyError: |
80 if key not in self.dict and default != KeyError: |
81 return [default][index] |
81 return [default][index] |
82 return self.dict[key][index] |
82 return self.dict[key][index] |
83 |
83 |
84 def iterallitems(self): |
84 def iterallitems(self): |
85 for key, values in self.dict.iteritems(): |
85 for key, values in self.dict.items(): |
86 for value in values: |
86 for value in values: |
87 yield key, value |
87 yield key, value |
88 |
88 |
89 def tob(data, enc='utf8'): # Convert strings to bytes (py2 and py3) |
89 def tob(data, enc='utf8'): # Convert strings to bytes (py2 and py3) |
90 return data.encode(enc) if isinstance(data, unicode) else data |
90 return data.encode(enc) if isinstance(data, unicode) else data |
398 raise MultipartError("Request to big. Increase MAXMEM.") |
398 raise MultipartError("Request to big. Increase MAXMEM.") |
399 data = stream.read(mem_limit) |
399 data = stream.read(mem_limit) |
400 if stream.read(1): # These is more that does not fit mem_limit |
400 if stream.read(1): # These is more that does not fit mem_limit |
401 raise MultipartError("Request to big. Increase MAXMEM.") |
401 raise MultipartError("Request to big. Increase MAXMEM.") |
402 data = parse_qs(data, keep_blank_values=True) |
402 data = parse_qs(data, keep_blank_values=True) |
403 for key, values in data.iteritems(): |
403 for key, values in data.items(): |
404 for value in values: |
404 for value in values: |
405 forms[key] = value.decode(charset) |
405 forms[key] = value.decode(charset) |
406 else: |
406 else: |
407 raise MultipartError("Unsupported content type.") |
407 raise MultipartError("Unsupported content type.") |
408 except MultipartError: |
408 except MultipartError: |