From da3faf9d29d9818669f1ef17d7e319d1dbd55b81 Mon Sep 17 00:00:00 2001 From: Michele Tartara <mtartara@google.com> Date: Tue, 26 Mar 2013 10:33:21 +0100 Subject: [PATCH] Add infrastructure for adding common RAPI parameters Some parameters can be common to all the RAPI calls: this commit adds the possibility of specifying them just once, instead of manually adding them to the classes describing each call. Signed-off-by: Michele Tartara <mtartara@google.com> Reviewed-by: Helga Velroyen <helgav@google.com> --- lib/rapi/baserlib.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rapi/baserlib.py b/lib/rapi/baserlib.py index 44da78c1d..95963738d 100644 --- a/lib/rapi/baserlib.py +++ b/lib/rapi/baserlib.py @@ -496,7 +496,17 @@ class OpcodeResource(ResourceBase): def _GetDefaultData(self): return (self.request_body, None) + def _GetCommonStatic(self): + """Return the static parameters common to all the RAPI calls + + """ + common_static = {} + return common_static + def _GenericHandler(self, opcode, rename, fn): - (body, static) = fn() + (body, specific_static) = fn() + static = self._GetCommonStatic() + if specific_static: + static.update(specific_static) op = FillOpcode(opcode, body, static, rename=rename) return self.SubmitJob([op]) -- GitLab