def get_int_arg(request, field, default=None):
    """Try to get an integer value from a query arg."""
    try:
        val = int(request.arguments.get(field, [default])[0])
    except (ValueError, TypeError):
        val = default
    return val