示例#1
0
 def replyer(x):
     a = x.group()[1:]
     i = find(Comment.id).filter_by(author=a).order_by(Comment.date).all()
     if i: reply.append(i[-1][0])
     return i and '@<a href="/{0}/reply?{1}#new">{2}</a>'.\
                  format(site, i[-1][0], a)\
              or "@{0}".format(a)
示例#2
0
def _create_session(web, mode):
    try:
        reply = int(web.input('reply') or web['QUERY_STRING'])
        author = find(Comment.author).filter_by(id = reply).one()[0]
        text = "@{0} ".format(author)
    except: text = ""
    try: reply = int(web.input('reply') or -1)
    except: reply = -1
    name = web.input("author") or ""
    if web.input("comment"): text = web.input("comment")
    a, b, c = randint(1, 10), randint(1, 10), randint(1, 10)
    hash = sha1(bytes(str(random()),'utf-8')).hexdigest()
    if mode in ["comment", "rate", "reply"]:
        cats = [ chr(65+i) for i in range(4) if randint(0, 1) ]
        if not len(cats): cats = [chr(65+randint(0, 3))]
        elif len(cats) == 4: cats.pop(randint(0, 3))
        pics = list(range(16)); shuffle(pics); pics = pics[:4]
        comment_hashes[hash] = (now(), a + b + c, cats, pics)
    return reply, text, name, hash, a, b, c