Make BaseMessage instances appear a bit more like JSON so they can make it through moksha validation.

This commit is contained in:
Ralph Bean
2016-12-15 13:50:43 -05:00
committed by Matt Prahl
parent c9d1a000be
commit 908f440357

View File

@@ -43,6 +43,10 @@ class BaseMessage(object):
"""
self.msg_id = msg_id
# Unused; just placeholder attributes to appear more like JSON.
self.body = {}
self.topic = None
def __repr__(self):
init_sig = signature(self.__init__)
@@ -54,6 +58,15 @@ class BaseMessage(object):
return "{}({})".format(type(self).__name__, ', '.join(args_strs))
def __getitem__(self, key):
return getattr(self, key)
def __setitem__(self, key, value):
return setattr(self, key, value)
def get(self, key, value=None):
return getattr(self, key, value)
@staticmethod
def from_amq(topic, msg):
msg_obj = None