diff options
author | Devin Carlen <devin.carlen@gmail.com> | 2010-10-01 02:28:31 -0700 |
---|---|---|
committer | Devin Carlen <devin.carlen@gmail.com> | 2010-10-01 02:28:31 -0700 |
commit | 4b3d4eb51a5d927a8eecdca550e04fc699443d21 (patch) | |
tree | f8299aef65d76d3e003fe0c42d94c9df66eb5ee9 /nova/wsgi.py | |
parent | c9e14d6257f0b488bd892c09d284091c0f612dd7 (diff) | |
parent | c9cb22f87561fad4ba57865d8a614ca024393f13 (diff) | |
download | nova-4b3d4eb51a5d927a8eecdca550e04fc699443d21.tar.gz nova-4b3d4eb51a5d927a8eecdca550e04fc699443d21.tar.xz nova-4b3d4eb51a5d927a8eecdca550e04fc699443d21.zip |
Merged trunk
Diffstat (limited to 'nova/wsgi.py')
-rw-r--r-- | nova/wsgi.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/nova/wsgi.py b/nova/wsgi.py index da9374542..b91d91121 100644 --- a/nova/wsgi.py +++ b/nova/wsgi.py @@ -230,6 +230,15 @@ class Controller(object): serializer = Serializer(request.environ, _metadata) return serializer.to_content_type(data) + def _deserialize(self, data, request): + """ + Deserialize the request body to the response type requested in request. + Uses self._serialization_metadata if it exists, which is a dict mapping + MIME types to information needed to serialize to that type. + """ + _metadata = getattr(type(self), "_serialization_metadata", {}) + serializer = Serializer(request.environ, _metadata) + return serializer.deserialize(data) class Serializer(object): """ @@ -272,10 +281,13 @@ class Serializer(object): The string must be in the format of a supported MIME type. """ datastring = datastring.strip() - is_xml = (datastring[0] == '<') - if not is_xml: - return json.loads(datastring) - return self._from_xml(datastring) + try: + is_xml = (datastring[0] == '<') + if not is_xml: + return json.loads(datastring) + return self._from_xml(datastring) + except: + return None def _from_xml(self, datastring): xmldata = self.metadata.get('application/xml', {}) |