formencode.variabledecode – Turn flat HTML form submissions into nested structures¶
Takes GET/POST variable dictionary, as might be returned by
and turns them into lists and dictionaries.
Keys (variable names) can have subkeys, with a
can be numbered with
a.b-3=something means that
a is a dictionary with a key
is a list, the third(-ish) element with the value
Numbers are used to sort, missing numbers are ignored.
This doesn’t deal with multiple keys, like in a query string of
id=10&id=20, which returns something like
'20']}. That’s left to someplace else to interpret. If you want to
represent lists in this model, you use indexes, and the lists are
If you want to change the character that determines when to split for
a dict or list, both variable_decode and variable_encode take dict_char
and list_char keyword args. For example, to have the GET/POST variables,
a_1=something as a list, you would use a
variable_decode(d, dict_char='.', list_char='-')¶
Decode the flat dictionary d into a nested structure.
variable_encode(d, prepend='', result=None, add_repetitions=True, dict_char='.', list_char='-')¶
Encode a nested structure into a flat dictionary.
- The input must be a string (not a
- Please enter a value
- The input must be a string (not None)