Exemplo n.º 1
0
def flag_topic(tid):
    key = 'flag:%d:t-%d' % (current_user.id, tid)
    if cache.get(key):
        return '', 204
    cache.inc(key)
    TopicStat(tid).flag()
    return '', 204
Exemplo n.º 2
0
def flag_topic(tid):
    key = 'flag:%d:t-%d' % (current_user.id, tid)
    if cache.get(key):
        return '', 204
    cache.inc(key)
    TopicStat(tid).flag()
    return '', 204
Exemplo n.º 3
0
def flag_topic_comment(tid, cid):
    key = 'flag:%d:c-%d' % (current_user.id, cid)
    if cache.get(key):
        return '', 204
    comment = get_comment_or_404(tid, cid)
    # here is a concurrency bug, but it doesn't matter
    comment.flag_count += 1
    with db.auto_commit():
        db.session.add(comment)
    # one person, one flag
    cache.inc(key)
    return '', 204
Exemplo n.º 4
0
def flag_topic_comment(tid, cid):
    key = 'flag:%d:c-%d' % (current_user.id, cid)
    if cache.get(key):
        return '', 204
    comment = get_comment_or_404(tid, cid)
    # here is a concurrency bug, but it doesn't matter
    comment.flag_count += 1
    with db.auto_commit():
        db.session.add(comment)
    # one person, one flag
    cache.inc(key)
    return '', 204
Exemplo n.º 5
0
 def receive_after_insert(mapper, conn, target):
     cache.inc(target.generate_cache_prefix('count'))