def build_complex_dict(self):
        raw_data = cgi.FieldStorage(fp=StringIO.StringIO(self.body), environ=self._environ)
        query_dict = {}

        for field in raw_data:
            if isinstance(raw_data[field], list):
                # Since it's a list of multiple items, we must have seen more than
                # one item of the same name come in. Store all of them.
                query_dict[field] = [fs.value for fs in raw_data[field]]
            elif raw_data[field].filename:
                # We've got a file.
                query_dict[field] = raw_data[field]
            else:
                query_dict[field] = raw_data[field].value

        return query_dict
Takes POST/PUT data and rips it apart into a dict.
dataset/ETHPy150Open toastdriven/itty/itty.py/Request.build_complex_dict