+ c.owner_url = owner_url
+ c.root_comment_id = id
+
+ if id:
+ # Get a thread starting from a certain point
+ c.root_comment = Comment.query.get(id)
+ if c.root_comment.discussion != owner_object.discussion:
+ abort(404)
+
+ c.comments = Comment.query.filter(and_(
+ Comment.discussion_id == owner_object.discussion_id,
+ Comment.left > c.root_comment.left,
+ Comment.right < c.root_comment.right
+ )).all()
+ else:
+ # Get everything
+ c.root_comment = None
+ c.comments = owner_object.discussion.comments
+