Skip to content

Commit b174982

Browse files
committed
Make REST-API updates work with WSGI
Now the Content-Type header is handled specially, it doesn't have a HTTP_ prefix in WSGI. Also make some form lookups more robust in rest.
1 parent 044d7ef commit b174982

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

roundup/cgi/wsgi_handler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ def __init__(self, environ):
2828
self.environ = environ
2929

3030
def mangle_name(self, name):
31+
""" Content-Type is handled specially, it doesn't have a HTTP_
32+
prefix in cgi.
33+
"""
3134
n = name.replace('-', '_').upper()
35+
if n == 'CONTENT_TYPE':
36+
return n
3237
return 'HTTP_' + n
3338

3439
def get(self, name, default = None):

roundup/rest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,9 @@ def dispatch(self, method, uri, input):
18281828
# check for pretty print
18291829
try:
18301830
pretty_output = not input['@pretty'].value.lower() == "false"
1831-
except KeyError:
1831+
# Can also return a TypeError ("not indexable")
1832+
# In case the FieldStorage could not parse the result
1833+
except (KeyError, TypeError):
18321834
pretty_output = True
18331835

18341836
# check for @apiver in query string
@@ -1838,7 +1840,9 @@ def dispatch(self, method, uri, input):
18381840
try:
18391841
if not self.api_version:
18401842
self.api_version = int(input['@apiver'].value)
1841-
except KeyError:
1843+
# Can also return a TypeError ("not indexable")
1844+
# In case the FieldStorage could not parse the result
1845+
except (KeyError, TypeError):
18421846
self.api_version = None
18431847
except ValueError:
18441848
output = self.error_obj(400, msg%input['@apiver'].value)

0 commit comments

Comments
 (0)