serve.py
def discuss():
    """ return discussion related to a paper """
    pid = request.args.get("id", "")  # paper id of paper we wish to discuss
    papers = [db[pid]] if pid in db else []

    # fetch the comments
    comms_cursor = comments.find({"pid": pid}).sort(
        [("time_posted", pymongo.DESCENDING)]
    )
    comms = list(comms_cursor)
    for c in comms:
        # have to convert these to strs from ObjectId, and backwards later http://api.mongodb.com/python/current/tutorial.html
        c["_id"] = str(c["_id"])

    # fetch the counts for all tags
    tag_counts = []
    for c in comms:
        cc = [
            tags_collection.count({"comment_id": c["_id"], "tag_name": t}) for t in TAGS
        ]
        tag_counts.append(cc)

    # and render
    ctx = default_context(
        papers,
        render_format="default",
        comments=comms,
        gpid=pid,
        tags=TAGS,
        tag_counts=tag_counts,
    )
    return render_template("discuss.html", **ctx)
 return discussion related to a paper 
return discussion related to a paper
return discussion related to a paper
def discuss():
    pid = request.args.get("id", "")  
    papers = [db[pid]] if pid in db else []
    comms_cursor = comments.find({"pid": pid}).sort(
        [("time_posted", pymongo.DESCENDING)]
    )
    comms = list(comms_cursor)
    for c in comms:
        c["_id"] = str(c["_id"])
    tag_counts = []
    for c in comms:
        cc = [
            tags_collection.count({"comment_id": c["_id"], "tag_name": t}) for t in TAGS
        ]
        tag_counts.append(cc)
    ctx = default_context(
        papers,
        render_format="default",
        comments=comms,
        gpid=pid,
        tags=TAGS,
        tag_counts=tag_counts,
    )
    return render_template("discuss.html", **ctx)
def discuss ( ) : pid = request . args . get ( "id" , "" ) papers = [ db [ pid ] ] if pid in db else [ ] comms_cursor = comments . find ( { "pid" : pid } ) . sort ( [ ( "time_posted" , pymongo . DESCENDING ) ] ) comms = list ( comms_cursor ) for c in comms : c [ "_id" ] = str ( c [ "_id" ] ) tag_counts = [ ] for c in comms : cc = [ tags_collection . count ( { "comment_id" : c [ "_id" ] , "tag_name" : t } ) for t in TAGS ] tag_counts . append ( cc ) ctx = default_context ( papers , render_format = "default" , comments = comms , gpid = pid , tags = TAGS , tag_counts = tag_counts , ) return render_template ( "discuss.html" , ** ctx )
return discussion related to a paper
return discussion related to a paper
""" return discussion related to a paper """ # paper id of paper we wish to discuss # fetch the comments # have to convert these to strs from ObjectId, and backwards later http://api.mongodb.com/python/current/tutorial.html # fetch the counts for all tags # and render