Add infrastructure for adding common RAPI parameters
authorMichele Tartara <mtartara@google.com>
Tue, 26 Mar 2013 09:33:21 +0000 (10:33 +0100)
committerMichele Tartara <mtartara@google.com>
Mon, 22 Apr 2013 11:18:04 +0000 (11:18 +0000)
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

index 44da78c..9596373 100644 (file)
@@ -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])