mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 11:48:33 +08:00
Make BaseMessage instances appear a bit more like JSON so they can make it through moksha validation.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user