chalice icon indicating copy to clipboard operation
chalice copied to clipboard

Set list as an item in MultiDict

Open tfotis opened this issue 9 months ago • 0 comments

It would be nice if there can be a way to set a list as an item in a MultiDict object.

This is currently only possible if you re-create the object.

Examples

from chalice.app import MultiDict
m = MultiDict(None)
m["a"] = ["a1", "a2"]
print(m)
// MultiDict({'a': [['a1', 'a2']]})  # list is inserted in a list
from chalice.app import MultiDict
m = MultiDict({"a": ["a1", "a2"]})
print(m)
// MultiDict({'a': ['a1', 'a2']})  # list is OK, as it was provided during object creation

So maybe the correct functionality for __setitem__ would be the following:

from chalice.app import MultiDict
m = MultiDict(None)
m["a"] = ["a1", "a2"]
print(m)
// MultiDict({'a': ['a1', 'a2']})

tfotis avatar May 21 '24 07:05 tfotis