comparison roundup/rest.py @ 5823:edd9e2c67785

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.
author Ralf Schlatterbeck <rsc@runtux.com>
date Sun, 23 Jun 2019 14:46:05 +0200
parents bab86c874efb
children 352e78c3b4ab
comparison
equal deleted inserted replaced
5822:ea9a892ba180 5823:edd9e2c67785
1826 output = self.error_obj(400, msg) 1826 output = self.error_obj(400, msg)
1827 1827
1828 # check for pretty print 1828 # check for pretty print
1829 try: 1829 try:
1830 pretty_output = not input['@pretty'].value.lower() == "false" 1830 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):
1832 pretty_output = True 1834 pretty_output = True
1833 1835
1834 # check for @apiver in query string 1836 # check for @apiver in query string
1835 msg=( "Unrecognized version: %s. " 1837 msg=( "Unrecognized version: %s. "
1836 "See /rest without specifying version " 1838 "See /rest without specifying version "
1837 "for supported versions." ) 1839 "for supported versions." )
1838 try: 1840 try:
1839 if not self.api_version: 1841 if not self.api_version:
1840 self.api_version = int(input['@apiver'].value) 1842 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):
1842 self.api_version = None 1846 self.api_version = None
1843 except ValueError: 1847 except ValueError:
1844 output = self.error_obj(400, msg%input['@apiver'].value) 1848 output = self.error_obj(400, msg%input['@apiver'].value)
1845 1849
1846 # by this time the API version is set. Error if we don't 1850 # by this time the API version is set. Error if we don't

Roundup Issue Tracker: http://roundup-tracker.org/