+
+ def _checkIntVariable(self, name, default=0):
+ """Return the parsed value of an int argument.
+
+ """
+ val = self.queryargs.get(name, default)
+ if isinstance(val, list):
+ if val:
+ val = val[0]
+ else:
+ val = default
+ try:
+ val = int(val)
+ except (ValueError, TypeError):
+ raise http.HttpBadRequest("Invalid value for the"
+ " '%s' parameter" % (name,))
+ return val
+
+ def _checkStringVariable(self, name, default=None):
+ """Return the parsed value of an int argument.
+
+ """
+ val = self.queryargs.get(name, default)
+ if isinstance(val, list):
+ if val:
+ val = val[0]
+ else:
+ val = default
+ return val
+
+ def getBodyParameter(self, name, *args):
+ """Check and return the value for a given parameter.
+
+ If a second parameter is not given, an error will be returned,
+ otherwise this parameter specifies the default value.
+
+ @param name: the required parameter
+
+ """
+ if name in self.req.request_body:
+ return self.req.request_body[name]
+ elif args:
+ return args[0]
+ else:
+ raise http.HttpBadRequest("Required parameter '%s' is missing" %
+ name)
+
+ def useLocking(self):
+ """Check if the request specifies locking.
+
+ """
+ return self._checkIntVariable('lock')
+
+ def useBulk(self):
+ """Check if the request specifies bulk querying.
+
+ """
+ return self._checkIntVariable('bulk')
+
+ def useForce(self):
+ """Check if the request specifies a forced operation.
+
+ """
+ return self._checkIntVariable('force')
+
+ def dryRun(self):
+ """Check if the request specifies dry-run mode.
+
+ """
+ return self._checkIntVariable('dry-run')