Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

decoding pyramid POST data (MultiDict Object)

I am receiving a POST request with data formatted as a MultiDict Object. Where can I find documentation about this data structure? and what is the best method (library) to decode these data into a dictionary object (with lists and dictionaries inside)

I did find this, in urllib3, but not sure if that's the. preferred way.

I already have written most of the code to match this style of data, so not really looking forward to changing the way the data is sent from the HTML form itself.

Thank you

like image 440
xcorat Avatar asked Dec 27 '22 05:12

xcorat


1 Answers

MultiDict is part of the WebOb project, see it's MultiDict documenation.

A MultiDict acts mostly just like a python dictionary, except that you can explicitly ask for one value or for a list of values with the .getone() and .getall() methods.

.mixed() returns a dictionary with single and list values as needed to represent each key, or you can use .dict_of_lists() to produce lists for all keys.

like image 66
Martijn Pieters Avatar answered Dec 28 '22 22:12

Martijn Pieters