diff options
author | Cerberus <matt.dietz@rackspace.com> | 2010-10-01 00:58:17 +0000 |
---|---|---|
committer | Tarmac <> | 2010-10-01 00:58:17 +0000 |
commit | 30747bba76ddc2b51b5b0bf564557e86a5d634c3 (patch) | |
tree | e420ee053b66d5c72eeb78855874121be9867128 /nova/wsgi.py | |
parent | 2212683888d717d55531136cf4917da015a2bb9c (diff) | |
parent | 75c5ba6aae6a57a61771ed78b6797c90f7da6940 (diff) | |
download | nova-30747bba76ddc2b51b5b0bf564557e86a5d634c3.tar.gz nova-30747bba76ddc2b51b5b0bf564557e86a5d634c3.tar.xz nova-30747bba76ddc2b51b5b0bf564557e86a5d634c3.zip |
Includes changes for creating instances via the Rackspace API. Utilizes much of the existing EC2 functionality to power the Rackspace side of things, at least for now.
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', {}) |