def _parse_positive_int_param(request, query_params, param_name):
  """Parses and asserts a positive (>0) integer query parameter.

  Args:
    request: The http request object.
    query_params: Dictionary of query parameters.
    param_name: Name of the parameter.

  Returns:
    None if parameter not present. -1 if parameter is not a positive integer.
  """
  param = query_params.get(param_name)
  if not param:
    return None
  try:
    param = int(param)
    if param <= 0:
      raise ValueError()
    return param
  except ValueError:
    request.respond('query parameter "%s" must be integer > 0' % param_name,
                    'text/plain', 400)
    return -1