Home / Function/ update() — flask Function Reference

update() — flask Function Reference

Architecture documentation for the update() function in blog.py from the flask codebase.

Entity Profile

Dependency Diagram

graph TD
  fe77837e_4ce8_4387_7787_f2c57dfffbd4["update()"]
  bf08e60d_e030_cf15_e246_1de85afd9b5e["blog.py"]
  fe77837e_4ce8_4387_7787_f2c57dfffbd4 -->|defined in| bf08e60d_e030_cf15_e246_1de85afd9b5e
  ba537604_373f_16e2_0f76_bee43f343f15["get_post()"]
  fe77837e_4ce8_4387_7787_f2c57dfffbd4 -->|calls| ba537604_373f_16e2_0f76_bee43f343f15
  adc04a87_eacf_cc39_8808_98d7d38c7044["get_db()"]
  fe77837e_4ce8_4387_7787_f2c57dfffbd4 -->|calls| adc04a87_eacf_cc39_8808_98d7d38c7044
  style fe77837e_4ce8_4387_7787_f2c57dfffbd4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/tutorial/flaskr/blog.py lines 88–110

def update(id):
    """Update a post if the current user is the author."""
    post = get_post(id)

    if request.method == "POST":
        title = request.form["title"]
        body = request.form["body"]
        error = None

        if not title:
            error = "Title is required."

        if error is not None:
            flash(error)
        else:
            db = get_db()
            db.execute(
                "UPDATE post SET title = ?, body = ? WHERE id = ?", (title, body, id)
            )
            db.commit()
            return redirect(url_for("blog.index"))

    return render_template("blog/update.html", post=post)

Subdomains

Frequently Asked Questions

What does update() do?
update() is a function in the flask codebase, defined in examples/tutorial/flaskr/blog.py.
Where is update() defined?
update() is defined in examples/tutorial/flaskr/blog.py at line 88.
What does update() call?
update() calls 2 function(s): get_db, get_post.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free