amqplib backend: Properly support Message.properties + Message.headers

This commit is contained in:
Ask Solem 2010-07-31 14:25:53 +02:00
parent 4c9ac1436e
commit 46bd38757b
1 changed files with 11 additions and 12 deletions

View File

@ -112,17 +112,16 @@ class Message(BaseMessage):
""" """
def __init__(self, channel, amqp_message, **kwargs): def __init__(self, channel, msg, **kwargs):
self.channel = channel super(Message, self).__init__(channel,
body=msg.body,
for attr_name in ("body", delivery_tag=msg.delivery_tag,
"delivery_tag", content_type=msg.content_type,
"content_type", content_encoding=msg.content_encoding,
"content_encoding", delivery_info=msg.delivery_info,
"delivery_info"): properties=msg.properties,
kwargs[attr_name] = getattr(amqp_message, attr_name, None) headers=msg.application_headers,
**kwargs)
super(Message, self).__init__(channel, **kwargs)
class Channel(Channel): class Channel(Channel):
@ -140,7 +139,7 @@ class Channel(Channel):
def message_to_python(self, raw_message): def message_to_python(self, raw_message):
"""Convert encoded message body back to a Python value.""" """Convert encoded message body back to a Python value."""
return self.Message(channel=self, amqp_message=raw_message) return self.Message(self, raw_message)
class Backend(BaseBackend): class Backend(BaseBackend):