get_post() — flask Function Reference
Architecture documentation for the get_post() function in blog.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD ba537604_373f_16e2_0f76_bee43f343f15["get_post()"] bf08e60d_e030_cf15_e246_1de85afd9b5e["blog.py"] ba537604_373f_16e2_0f76_bee43f343f15 -->|defined in| bf08e60d_e030_cf15_e246_1de85afd9b5e fe77837e_4ce8_4387_7787_f2c57dfffbd4["update()"] fe77837e_4ce8_4387_7787_f2c57dfffbd4 -->|calls| ba537604_373f_16e2_0f76_bee43f343f15 0ed96e73_8dd2_07eb_7979_5188239e570c["delete()"] 0ed96e73_8dd2_07eb_7979_5188239e570c -->|calls| ba537604_373f_16e2_0f76_bee43f343f15 adc04a87_eacf_cc39_8808_98d7d38c7044["get_db()"] ba537604_373f_16e2_0f76_bee43f343f15 -->|calls| adc04a87_eacf_cc39_8808_98d7d38c7044 style ba537604_373f_16e2_0f76_bee43f343f15 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
examples/tutorial/flaskr/blog.py lines 28–57
def get_post(id, check_author=True):
"""Get a post and its author by id.
Checks that the id exists and optionally that the current user is
the author.
:param id: id of post to get
:param check_author: require the current user to be the author
:return: the post with author information
:raise 404: if a post with the given id doesn't exist
:raise 403: if the current user isn't the author
"""
post = (
get_db()
.execute(
"SELECT p.id, title, body, created, author_id, username"
" FROM post p JOIN user u ON p.author_id = u.id"
" WHERE p.id = ?",
(id,),
)
.fetchone()
)
if post is None:
abort(404, f"Post id {id} doesn't exist.")
if check_author and post["author_id"] != g.user["id"]:
abort(403)
return post
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does get_post() do?
get_post() is a function in the flask codebase, defined in examples/tutorial/flaskr/blog.py.
Where is get_post() defined?
get_post() is defined in examples/tutorial/flaskr/blog.py at line 28.
What does get_post() call?
get_post() calls 1 function(s): get_db.
What calls get_post()?
get_post() is called by 2 function(s): delete, update.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free