From f2def43abca8c7e2b80577309698668e7227ff98 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 9 Feb 2009 09:24:21 +0000 Subject: [PATCH] RpcResult: add a new payload field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For results which use the (status, payload) response type, it's easier to define a βpayloadβ field on the result holding the payload than to extract it using βdata[1]β in the caller code. Reviewed-by: ultrotter --- lib/rpc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/rpc.py b/lib/rpc.py index 461c1c86d..12791fe24 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -104,13 +104,17 @@ class RpcResult(object): if offline: self.failed = True self.error = "Node is marked offline" - self.data = None + self.data = self.payload = None elif failed: self.error = data - self.data = None + self.data = self.payload = None else: self.data = data self.error = None + if isinstance(data, (tuple, list)) and len(data) == 2: + self.payload = data[1] + else: + self.payload = None def Raise(self): """If the result has failed, raise an OpExecError. -- GitLab