serve.py
def comment():
    """ user wants to post a comment """
    anon = int(request.form["anon"])

    if g.user and (not anon):
        username = get_username(session["user_id"])
    else:
        # generate a unique username if user wants to be anon, or user not logged in.
        username = "anon-%s-%s" % (str(int(time.time())), str(randrange(1000)))

    # process the raw pid and validate it, etc
    try:
        pid = request.form["pid"]
        if not pid in db:
            raise Exception("invalid pid")
        version = db[pid]["version"]  # most recent version of this paper
    except Exception as e:
        print(e)
        return "bad pid. This is most likely Andrej's fault."

    # create the entry
    entry = {
        "user": username,
        "pid": pid,  # raw pid with no version, for search convenience
        "version": version,  # version as int, again as convenience
        "conf": request.form["conf"],
        "anon": anon,
        "time_posted": time.time(),
        "text": request.form["text"],
    }

    # enter into database
    print(entry)
    comments.insert_one(entry)
    return "OK"
 user wants to post a comment 
user wants to post a comment
user wants to post a comment
def comment():
    anon = int(request.form["anon"])
    if g.user and (not anon):
        username = get_username(session["user_id"])
    else:
        username = "anon-%s-%s" % (str(int(time.time())), str(randrange(1000)))
    try:
        pid = request.form["pid"]
        if not pid in db:
            raise Exception("invalid pid")
        version = db[pid]["version"]  
    except Exception as e:
        print(e)
        return "bad pid. This is most likely Andrej's fault."
    entry = {
        "user": username,
        "pid": pid,  
        "version": version,  
        "conf": request.form["conf"],
        "anon": anon,
        "time_posted": time.time(),
        "text": request.form["text"],
    }
    print(entry)
    comments.insert_one(entry)
    return "OK"
def comment ( ) : anon = int ( request . form [ "anon" ] ) if g . user and ( not anon ) : username = get_username ( session [ "user_id" ] ) else : username = "anon-%s-%s" % ( str ( int ( time . time ( ) ) ) , str ( randrange ( 1000 ) ) ) try : pid = request . form [ "pid" ] if not pid in db : raise Exception ( "invalid pid" ) version = db [ pid ] [ "version" ] except Exception as e : print ( e ) return "bad pid. This is most likely Andrej's fault." entry = { "user" : username , "pid" : pid , "version" : version , "conf" : request . form [ "conf" ] , "anon" : anon , "time_posted" : time . time ( ) , "text" : request . form [ "text" ] , } print ( entry ) comments . insert_one ( entry ) return "OK"
user wants to post a comment
user wants to post a comment
""" user wants to post a comment """ # generate a unique username if user wants to be anon, or user not logged in. # process the raw pid and validate it, etc # most recent version of this paper # create the entry # raw pid with no version, for search convenience # version as int, again as convenience # enter into database