simpler logic in parse POST but not functional difference

This commit is contained in:
mdipierro
2013-09-19 17:47:29 -05:00
parent 146ea115bf
commit 1d2fc4b8f5
2 changed files with 11 additions and 18 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.6.3-stable+timestamp.2013.09.18.14.36.14 Version 2.6.3-stable+timestamp.2013.09.19.17.46.36
+10 -17
View File
@@ -211,10 +211,9 @@ class Request(Storage):
body.seek(0) body.seek(0)
# parse POST variables on POST, PUT, BOTH only in post_vars # parse POST variables on POST, PUT, BOTH only in post_vars
if (body and if (body and not is_json
env.request_method in ('POST', 'PUT', 'DELETE', 'BOTH') and and env.request_method in ('POST', 'PUT', 'DELETE', 'BOTH')):
not is_json): query_string = env.pop('QUERY_STRING',None)
query_string = env.pop('QUERY_STRING') if 'QUERY_STRING' in env else None
dpost = cgi.FieldStorage(fp=body, environ=env, keep_blank_values=1) dpost = cgi.FieldStorage(fp=body, environ=env, keep_blank_values=1)
post_vars.update(dpost) post_vars.update(dpost)
if query_string is not None: if query_string is not None:
@@ -232,19 +231,13 @@ class Request(Storage):
if key is None: if key is None:
continue # not sure why cgi.FieldStorage returns None key continue # not sure why cgi.FieldStorage returns None key
dpk = dpost[key] dpk = dpost[key]
# if an element is not a file replace it with its value else leave it alone # if an element is not a file replace it with
if isinstance(dpk, list): # its value else leave it alone
value = []
for _dpk in dpk: pvalue = listify([(_dpk if _dpk.filename else _dpk.value)
if not _dpk.filename: for _dpk in dpk]
value.append(_dpk.value) if isinstance(dpk, list) else
else: (dpk if dpk.filename else dpk.value))
value.append(_dpk)
elif not dpk.filename:
value = dpk.value
else:
value = dpk
pvalue = listify(value)
if len(pvalue): if len(pvalue):
post_vars[key] = (len(pvalue) > 1 and pvalue) or pvalue[0] post_vars[key] = (len(pvalue) > 1 and pvalue) or pvalue[0]