From 61c4cdec304d79f43c8a549c2543c939492c4812 Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Tue, 6 Aug 2013 20:27:18 +0000 Subject: Ensure context type is handled when using to_dict Handle the case where the context passed into def pack_context() is a dictionary. If a dictionary is passed in, we don't need to call to_dict before updating the msg. fixes bug 1208971 Change-Id: I2ce0b28f97634e717868e0ee5525189338d4981c --- openstack/common/rpc/amqp.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'openstack/common') diff --git a/openstack/common/rpc/amqp.py b/openstack/common/rpc/amqp.py index 1afd2ab..38f2515 100644 --- a/openstack/common/rpc/amqp.py +++ b/openstack/common/rpc/amqp.py @@ -300,8 +300,13 @@ def pack_context(msg, context): for args at some point. """ - context_d = dict([('_context_%s' % key, value) - for (key, value) in context.to_dict().iteritems()]) + if isinstance(context, dict): + context_d = dict([('_context_%s' % key, value) + for (key, value) in context.iteritems()]) + else: + context_d = dict([('_context_%s' % key, value) + for (key, value) in context.to_dict().iteritems()]) + msg.update(context_d) -- cgit