summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-06-13 15:03:26 -0400
committerBrian Waldon <brian.waldon@rackspace.com>2011-06-13 15:03:26 -0400
commitf2ca12fc5ea236bb8940acce80065a3bcbe37d2a (patch)
tree30d2c3c0fccdf049149e9085eed3b81224b04c96
parent8146b92f7d81eada6408f939ef25cb5393650008 (diff)
downloadnova-f2ca12fc5ea236bb8940acce80065a3bcbe37d2a.tar.gz
nova-f2ca12fc5ea236bb8940acce80065a3bcbe37d2a.tar.xz
nova-f2ca12fc5ea236bb8940acce80065a3bcbe37d2a.zip
wsgi can now handle dispatching action None more elegantly
-rw-r--r--nova/api/openstack/wsgi.py13
-rw-r--r--nova/tests/api/openstack/test_wsgi.py13
2 files changed, 19 insertions, 7 deletions
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index e71b80e2c..385ae4625 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -60,8 +60,9 @@ class TextDeserializer(object):
def deserialize(self, datastring, action='default'):
"""Find local deserialization method and parse request body."""
- action_method = getattr(self, action, self.default)
- return action_method(datastring)
+ action_method = getattr(self, str(action), self.default)
+ output = action_method(datastring)
+ return output
def default(self, datastring):
"""Default deserialization code should live here"""
@@ -189,11 +190,9 @@ class DictSerializer(object):
def serialize(self, data, action='default'):
"""Find local serialization method and encode response body."""
- if action is None:
- action_method = self.default
- else:
- action_method = getattr(self, action, self.default)
- return action_method(data)
+ action_method = getattr(self, str(action), self.default)
+ output = action_method(data)
+ return output
def default(self, data):
"""Default serialization code should live here"""
diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py
index 0329ab218..5ec7712dd 100644
--- a/nova/tests/api/openstack/test_wsgi.py
+++ b/nova/tests/api/openstack/test_wsgi.py
@@ -89,6 +89,13 @@ class DictSerializerTest(test.TestCase):
serializer.default = lambda x: 'trousers'
self.assertEqual(serializer.serialize({}, 'update'), 'trousers')
+ def test_dispatch_action_None(self):
+ serializer = wsgi.DictSerializer()
+ serializer.create = lambda x: 'pants'
+ serializer.default = lambda x: 'trousers'
+ self.assertEqual(serializer.serialize({}, None), 'trousers')
+
+
class XMLDictSerializerTest(test.TestCase):
def test_xml(self):
@@ -123,6 +130,12 @@ class TextDeserializerTest(test.TestCase):
deserializer.default = lambda x: 'trousers'
self.assertEqual(deserializer.deserialize({}, 'update'), 'trousers')
+ def test_dispatch_action_None(self):
+ deserializer = wsgi.TextDeserializer()
+ deserializer.create = lambda x: 'pants'
+ deserializer.default = lambda x: 'trousers'
+ self.assertEqual(deserializer.deserialize({}, None), 'trousers')
+
class JSONDeserializerTest(test.TestCase):
def test_json(self):