Fix immutable cursor issue

Address the issue of using an immutable cursor in the file
flaskr/blog.py. The previous implementation attempted to modify
the 'posts' object, which is immutable, leading to runtime
errors. This commit refactors the code to ensure that the
cursor is handled correctly, preventing any attempts to modify
immutable objects. This change resolves the problem by
introducing a mutable data structure to store the necessary
information, thereby maintaining the integrity of the cursor
and avoiding potential errors.
This commit is contained in:
Neo 2024-09-09 21:45:36 +00:00
parent 1d2f1348a4
commit c91d5733b1

View file

@ -24,8 +24,9 @@ def index():
" ORDER BY created DESC"
).fetchall()
# Convert markdown to HTML for each post body
for post in posts:
post['body'] = markdown.markdown(post['body'])
posts = [
{**post, 'body': markdown.markdown(post['body'])} for post in posts
]
return render_template("blog/index.html", posts=posts)