summaryrefslogtreecommitdiffstats
path: root/nova/wsgi.py
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-30 18:13:45 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-09-30 18:13:45 -0700
commit1dda065c53cbe11a34e7ae60e11e30dfaf6bf7ac (patch)
treed04a4ac2195d45e9c5f357039cab7d1c0cf40c3d /nova/wsgi.py
parent5d30881d721bdc9e26f71fd2130bd44e7edb1d4d (diff)
parent30747bba76ddc2b51b5b0bf564557e86a5d634c3 (diff)
downloadnova-1dda065c53cbe11a34e7ae60e11e30dfaf6bf7ac.tar.gz
nova-1dda065c53cbe11a34e7ae60e11e30dfaf6bf7ac.tar.xz
nova-1dda065c53cbe11a34e7ae60e11e30dfaf6bf7ac.zip
merged trunk
Diffstat (limited to 'nova/wsgi.py')
-rw-r--r--nova/wsgi.py20
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', {})