Parsed_body now raises ValueError if it can't find a parser.

This commit is contained in:
rdw
2008-03-20 14:54:50 -07:00
parent 3f6b50212f
commit 96eb7a660f

View File

@@ -369,10 +369,15 @@ class Request(object):
if not hasattr(self, '_cached_parsed_body'):
body = self.read_body()
if hasattr(self.site, 'parsers'):
parser = self.site.parsers.get(
self.get_header('content-type'))
ct = self.get_header('content-type')
parser = self.site.parsers.get(ct)
if parser is not None:
body = parser(body)
else:
ex = ValueError("Could not find parser for content-type: %s" % ct)
ex.body = body
raise ex
self._cached_parsed_body = body
return self._cached_parsed_body