@app.route("/product/<tiid>/pdf", methods=['GET'])
def product_pdf(tiid):

    if request.method == "GET":
        try:
            product = get_product(tiid)
            pdf = product.get_pdf()
            db.session.merge(product)  # get pdf might have cached the pdf
            commit(db)
            if pdf:
                resp = make_response(pdf, 200)
                resp.mimetype = "application/pdf"
                resp.headers.add("Content-Disposition",
                                 "attachment; filename=impactstory-{tiid}.pdf".format(
                                    tiid=tiid))   
                return resp

            else:
                abort_json(404, "This product exists, but has no pdf.")

        except __HOLE__:
            abort_json(404, "That product doesn't exist.")
        except S3ResponseError:
            abort_json(404, "This product exists, but has no pdf.")
dataset/ETHPy150Open Impactstory/total-impact-webapp/totalimpactwebapp/views.py/product_pdf