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:
parent
1d2f1348a4
commit
c91d5733b1
1 changed files with 3 additions and 2 deletions
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue