liveBook · Manning

Post

As explained in The Well-Grounded Python Developer: How the pros use Python and Flask

A blog post is a titled item of authored content published as part of a blog.

A post is a titled item of authored content published as part of a blog. It gathers the author, creation timestamp, update timestamp, title, and written content into one manageable unit. Registered users create posts, all users can view them, and users can comment on them. section 6.0 section 11.0

Treat a post as both user-facing content and an application resource:

  • Create it through a URL handler, input form, and template; review the content before saving it to the database. section 11.5
  • Display and edit individual posts alongside views that display multiple posts. section 11.6
  • Store Markdown in the database as text and render it when displaying the post. section 11.7
  • Attach comments through a self-referential post structure, allowing each post to have zero or many child posts. section 11.7

The same structure can represent both content posts and comments; comments mainly differ by lacking a title. A display handler retrieves the root post and its descendants, then renders them in meaningful hierarchical order. Recursive traversal processes each child until reaching a node without children, while a recursive common table expression supports the equivalent tree query in SQLAlchemy. section 11.7 section 11.7.2

Figure 11.5 The content and comment relationship structure forms a hierarchy.

Use the relationship diagram to follow a root content post through its nested comment posts and understand why the data forms a tree. section 11.7

How The Well-Grounded Python Developer: How the pros use Python and Flask covers it

How deep it goes
Explains post metadata, CRUD flow, Markdown rendering, self-reference, recursive traversal, and recursive SQL queries.
Examples
Uses MyBlog posts, URL handlers, forms, templates, database records, and nested comment trees as concrete examples.
What it assumes
Assumes web application, database, user-role, and Flask Blueprint infrastructure already exists.
What you can do after
Build a post workflow that creates, stores, edits, displays, and hierarchically renders blog content and comments.
How it connects
Connects posts to blogs, users, Markdown, databases, comments, self-referential relationships, SQLAlchemy, and recursive common table expressions.

Also explained in

Compare how 2 books explain post →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Python Developer: How the pros use Python and Flask. The section links point to the parts of the book it draws on.