def get_value_from_request(request, param, default, dtype=int):
    """Look for a value in GET and convert it to the given datatype."""
    try:
        v = dtype(request.GET.get(param, default))
    except:
        v = default
    return v