0
私はMessage
クラスのペイロードを設定したいと思っています。しかし、私はこれを行うための適切な方法を使用する方法を把握することはできません。これは、Message
クラスは、ソースコード(関係ない部分を削除しました)でどのように見えるかです:Python:デコレータでメソッドを正しく使う方法
class Message(object):
def __init__(self):
self._type = None
self._mid = None
self._token = None
self._options = []
self._payload = None
self._destination = None
self._source = None
self._code = None
self._acknowledged = None
self._rejected = None
self._timeouted = None
self._cancelled = None
self._duplicated = None
self._timestamp = None
self._version = 1
@property
def payload(self):
"""
Return the payload.
:return: the payload
"""
return self._payload
@payload.setter
def payload(self, value):
"""
Sets the payload of the message and eventually the Content-Type
:param value: the payload
"""
if isinstance(value, tuple):
content_type, payload = value
self.content_type = content_type
self._payload = payload
else:
self._payload = value
私はmessageObject.payload("Hello World")
とペイロードを設定しようとすると、私はエラーを取得:TypeError: 'NoneType' object is not callable
を。
ペイロードを設定する適切な方法は何ですか?