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.

Closes-Bug: #1208971
Change-Id: I2ce0b28f97634e717868e0ee5525189338d4981c
This commit is contained in:
Lance Bragstad 2013-12-03 15:18:41 +00:00 committed by Mark McLoughlin
parent fda06f6806
commit d04fab6985
1 changed files with 7 additions and 2 deletions

View File

@ -301,8 +301,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)