Example #1
0
def rating_get(rating_id, rating_key_str):
    """
    It retrieves the rating.

    Parameters:
    - rating_id: the string id of the Rating
    - rating_key_str: the urlsafe string representing the key.

    Only one between rating_id and rating_key_str should be set, since they represent the same information, 
    but encoded in two different ways. They are both accepted for generality. If both are set, the id is used.

    It returns a tuple: 
    - the requested rating (or None in case of errors in the input),
    - the status (a string indicating whether an error occurred),
    - the http code indicating the type of error, if any
    """
    try:
        res = Rating.get_by_key(Rating.make_key(rating_id, rating_key_str))
    except TypeError as e:
        return None, str(e), 400
    return res, "OK", 200