Ejemplo n.º 1
0
def single_product_get(tiid):
    cleaned_items_dict = cleaned_items([tiid], myredis)
    try:
        single_item = cleaned_items_dict[tiid]
    except TypeError:
        abort_custom(404, "No product found with that tiid")

    response_code = 200
    if collection.is_something_currently_updating(cleaned_items_dict, myredis):
        response_code = 210  # update is not complete yet

    resp = make_response(json.dumps(single_item, sort_keys=True, indent=4),
                         response_code)

    return resp
Ejemplo n.º 2
0
def single_product_get(tiid):
    cleaned_items_dict = cleaned_items([tiid], myredis)
    try:
        single_item = cleaned_items_dict[tiid]
    except TypeError:
        abort_custom(404, "No product found with that tiid")

    response_code = 200
    if collection.is_something_currently_updating(cleaned_items_dict, myredis):
        response_code = 210 # update is not complete yet

    resp = make_response(json.dumps(single_item, sort_keys=True, indent=4),
                         response_code)

    return resp
Ejemplo n.º 3
0
def products_get(tiids_string, format="json"):
    tiids = tiids_string.split(",")
    cleaned_items_dict = cleaned_items(tiids, myredis)

    response_code = 200
    if collection.is_something_currently_updating(cleaned_items_dict, myredis):
        response_code = 210 # update is not complete yet

    if format == "csv":
        csv = collection.make_csv_stream(cleaned_items_dict.values())
        resp = make_response(csv, response_code)
        resp.mimetype = "text/csv;charset=UTF-8"
        resp.headers.add("Content-Encoding", "UTF-8")
    else:
        resp = make_response(json.dumps({"products": cleaned_items_dict}, sort_keys=True, indent=4),
                             response_code)

    return resp
Ejemplo n.º 4
0
def products_get(tiids_string, format="json"):
    tiids = tiids_string.split(",")
    cleaned_items_dict = cleaned_items(tiids, myredis)

    response_code = 200
    if collection.is_something_currently_updating(cleaned_items_dict, myredis):
        response_code = 210  # update is not complete yet

    if format == "csv":
        csv = collection.make_csv_stream(cleaned_items_dict.values())
        resp = make_response(csv, response_code)
        resp.mimetype = "text/csv;charset=UTF-8"
        resp.headers.add("Content-Encoding", "UTF-8")
    else:
        resp = make_response(
            json.dumps({"products": cleaned_items_dict},
                       sort_keys=True,
                       indent=4), response_code)

    return resp