1.1 --- a/WebStack/Helpers/Request.py Thu Sep 02 19:32:22 2004 +0000
1.2 +++ b/WebStack/Helpers/Request.py Thu Sep 02 19:32:50 2004 +0000
1.3 @@ -134,4 +134,29 @@
1.4 else:
1.5 return field_str
1.6
1.7 +def get_fields_from_query_string(query_string, decoder):
1.8 +
1.9 + """
1.10 + Returns a dictionary mapping field names to lists of values for the data
1.11 + encoded in the given 'query_string'. Use the given 'decoder' function or
1.12 + method to process the URL-encoded values.
1.13 + """
1.14 +
1.15 + fields = {}
1.16 +
1.17 + for pair in query_string.split("&"):
1.18 + t = pair.split("=")
1.19 + name = decoder(t[0])
1.20 +
1.21 + if len(t) == 2:
1.22 + value = decoder(t[1])
1.23 + else:
1.24 + value = ""
1.25 +
1.26 + if not fields.has_key(name):
1.27 + fields[name] = []
1.28 + fields[name].append(value)
1.29 +
1.30 + return fields
1.31 +
1.32 # vim: tabstop=4 expandtab shiftwidth=4