Fix exception when serializing comments JSON.

The JSON API endpoints that return comments, most notably `/comments`
returned 500s and created a stack trace with:

  TypeError: Object of type method is not JSON serializable

Further debugging revealed this was because json.encoder was being
given a <bound method lazy.<locals>.wrapper of <Comment(id=123)>> to
serialize.

The introduction of the bug was traced to 8ecb4582d0 where it was
discovered that the (seemingly inadvertent) removal of the @property
decorator on classes/comment.py:parent_fullname was the root cause.

In light of the fact that parent_fullname was unrelated to the changes
intended in 8ecb4582d0 and that no other refactoring around
parent_fullname was done, it was restored to being a @property rather
than its callers modified to invoke it as a method.
remotes/1693045480750635534/spooky-22
Snakes 2022-06-24 15:26:18 -04:00
parent a2a9c2666d
commit 47159f338d
1 changed files with 1 additions and 0 deletions

View File

@ -235,6 +235,7 @@ class Comment(Base):
else: return g.db.get(Comment, self.parent_comment_id)
@property
@lazy
def parent_fullname(self):
if self.parent_comment_id: return f"t3_{self.parent_comment_id}"