def add_comment(comment, user, channel_id, video_id, parent_id): if not user or not channel_id or not video_id: return None video = _video_key(channel_id, video_id) comment = CommentModel( parent=video, comment=comment, user=user, channel_id=channel_id, video_id=video_id, parent_id=int(parent_id) ) comment.put() fastcounter.incr(video_comment_counter(channel_id, video_id)) return comment
def _build_comment_tree(channel_id, video_id): video = _video_key(channel_id, video_id) q = CommentModel.all() q.ancestor(video) comments = q.fetch(COMMENT_TREE_MAX_SIZE) tree = CommentTree(comments) _populate_comment_counters(channel_id, video_id, tree) return tree