Beispiel #1
0
    r = cursor.fetchone()
    if r:
        zsite_id = r[0]
        cursor.execute('delete from feed where id=%s', id)
        cursor.connection.commit()
        mc_feed_iter.delete(zsite_id)


def feed_rt_rm_by_rid(rid):
    cursor.execute('select id, zsite_id from feed where rid=%s', rid)
    for id, zsite_id in cursor:
        cursor.execute('delete from feed where id=%s', id)
        cursor.connection.commit()
        mc_feed_iter.delete(zsite_id)

mq_feed_rt_rm_by_rid = mq_client(feed_rt_rm_by_rid)

def feed_rt_rm(zsite_id, rid):
    ids = feed_rt_id_list(zsite_id, rid)
    if ids:
        for id in ids:
            _id = id[0]
            cursor.execute('delete from feed where id=%s', _id)
            from po import po_rm
            po_rm(zsite_id,_id)
            cursor.connection.commit()
            mc_feed_iter.delete(zsite_id)
            mc_feed_rt_id.delete('%s_%s'%(zsite_id, rid))

def feed_rt(zsite_id, rid):
    feed = Feed.mc_get(rid)
Beispiel #2
0
    buzz_to = buzz_to - excepted
    if buzz_to:
        now = int(time())
        for user_id in buzz_to:
            if BuzzAt.get(po_id=po_id, to_id=user_id, state=BUZZ_AT_SHOW ):
                continue

            buzz_reply = BuzzReply.get_or_create(po_id=po_id, user_id=user_id)
            buzz_reply.update_time = now
            buzz_reply.state = BUZZ_REPLY_STATE_SHOW
            buzz_reply.save()
            mc_flush(user_id)


mq_buzz_po_reply_new = mq_client(buzz_po_reply_new)

def buzz_po_reply_rm(po_id, reply_id):
    from po_pos import PoPos, STATE_BUZZ
    from model.po import Po
    po = Po.mc_get(po_id)
    if not po:
        return
    reply_id_last = po.reply_id_last
    if po and reply_id >= reply_id_last:
        for user_id in PoPos.where(po_id=po_id, state=STATE_BUZZ).where('pos>=%s', reply_id_last).col_list(col='user_id'):
            BuzzReply.where(po_id=po_id, user_id=user_id, state=BUZZ_REPLY_STATE_SHOW).update(state=BUZZ_REPLY_STATE_HIDE)
            mc_flush(user_id)
    buzz_at_reply_rm(reply_id)

mq_buzz_po_reply_rm = mq_client(buzz_po_reply_rm)
Beispiel #3
0
from cid import CID_REC

mc_po_recommend_id_by_rid_user_id = McCache('PoRecommendIdByRidUserId:%s')
mc_reply_id_by_recommend = McCache('ReplyIdByRecommend:%s')

class RecRep(McModel):
    pass


def rm_rec_po_by_po_id(user_id,id):
    ''' DANGEROUS USE WITH CAUTION '''
    for po in Po.where('cid = %s and rid=%s',CID_REC,id):
        po_rm(po.user_id,po.id)

from mq import mq_client
mq_rm_rec_po_by_po_id = mq_client(rm_rec_po_by_po_id)

def po_recommend_new(rid, user_id, name, reply_id=None):
    '''新建推荐'''
    #判定?
    rec_po = Po.mc_get(rid)
    if not rec_po:
        return
    from po_pos import po_pos_state_buzz
    po_pos_state_buzz(user_id, rec_po)

    recommend = po_new(
        CID_REC,
        user_id,
        name,
        state=STATE_ACTIVE,
Beispiel #4
0
             to_id=to_id,
             cid=cid,
             rid=rid,
             create_time=int(time()))
    b.save()
    mc_flush(to_id)
    buzz_unread_update(to_id)
    return b


def buzz_po_fav_new(from_id, po_id):
    for i in ormiter(Follow, 'to_id=%s and from_id!=%s' % (from_id, from_id)):
        buzz_new(from_id, i.from_id, CID_BUZZ_PO_FAV, po_id)


mq_buzz_po_fav_new = mq_client(buzz_po_fav_new)


def buzz_sys_new(user_id, rid):
    buzz_new(0, user_id, CID_BUZZ_SYS, rid)


def buzz_sys_new_all(rid):
    for i in ormiter(Zsite,
                     'cid=%s and state>=%s' % (CID_USER, ZSITE_STATE_ACTIVE)):
        buzz_sys_new(i.id, rid)


#mq_buzz_sys_new_all = mq_client(buzz_sys_new_all)

Beispiel #5
0
    kwds['sender'] = sender
    kwds['sender_name'] = sender_name
    kwds['site_name'] = SITE_NAME
    kwds['site_domain'] = SITE_DOMAIN
    kwds['site_http'] = SITE_HTTP
    text = render_template(uri, **kwds)

    if subject is None:
        r = text.split('\n', 1)

        if len(r) < 2:
            r.append(r[0])

        if uri.endswith('.txt'):
            r[1] = r[1].replace('\n', '\n\n')

        subject = str(r[0])
        text = str(r[1])

#    print subject, '\n\n', text
#    return
    sendmail(subject, text, email, name, sender, sender_name, format)

from mq import mq_client
mq_rendermail = mq_client(rendermail)

if '__main__' == __name__:
    from time import time
    sendmail('time %s'%time(), '2345', '*****@*****.**')
    print SENDER_MAIL
Beispiel #6
0
        for i in po_list_by_buzz_at_user_id(user_id):
            po_id = i[0]
            BuzzAt.where(po_id=po_id,to_id=user_id).update(state=BUZZ_AT_HIDE)
    mc_flush(user_id)

def buzz_at_new(from_id, txt, po_id, reply_id=0):
    at_id_set = at_id_set_by_txt(txt)
    for to_id in at_id_set:
        buzz_at = BuzzAt(from_id=from_id, to_id=to_id, reply_id=reply_id, po_id=po_id, state=BUZZ_AT_SHOW)
        buzz_at.save()
        mc_flush(to_id)
        mc_po_list_by_buzz_at_user_id.delete(to_id)

    return at_id_set

mq_buzz_at_new = mq_client(buzz_at_new)


def buzz_at_reply_rm(reply_id):
    from model.reply import Reply
    txt = txt_get(reply_id)
    if not txt:
        return
    at_id_set = at_id_set_by_txt(txt)
    for to_id in at_id_set:
        BuzzAt.where(to_id=to_id, reply_id=reply_id).update(state=BUZZ_AT_RMED)
        mc_flush(to_id)

BUZZ_AT_COL = 'id,from_id,po_id,reply_id'

Beispiel #7
0
    buzz_count.delete(user_id)
    mc_buzz_list.delete(user_id)
    #buzz_unread_count.delete(user_id)

def buzz_new(from_id, to_id, cid, rid):
    b = Buzz(from_id=from_id, to_id=to_id, cid=cid, rid=rid, create_time=int(time()))
    b.save()
    mc_flush(to_id)
    buzz_unread_update(to_id)
    return b

def buzz_po_fav_new(from_id, po_id):
    for i in ormiter(Follow, 'to_id=%s and from_id!=%s' % (from_id, from_id)):
        buzz_new(from_id, i.from_id, CID_BUZZ_PO_FAV, po_id)
    
mq_buzz_po_fav_new = mq_client(buzz_po_fav_new)

def buzz_sys_new(user_id, rid):
    buzz_new(0, user_id, CID_BUZZ_SYS, rid)

def buzz_sys_new_all(rid):
    for i in ormiter(Zsite, 'cid=%s and state>=%s' % (CID_USER, ZSITE_STATE_ACTIVE)):
        buzz_sys_new(i.id, rid)

#mq_buzz_sys_new_all = mq_client(buzz_sys_new_all)



def buzz_follow_new(from_id, to_id):
    if not Buzz.where(from_id=from_id, to_id=to_id, cid=CID_BUZZ_FOLLOW, rid=to_id).count():
        buzz_new(from_id, to_id, CID_BUZZ_FOLLOW, to_id)
Beispiel #8
0
    notice_po = Po.mc_get(po_id)
    txt = notice_po.name
    notice_link = notice_po.link
    for user_id in event_joiner_user_id_list(event_id):
        notice_new(from_id, user_id, CID_NOTICE_EVENT_NOTICE, po_id)
        name = Zsite.mc_get(user_id).name
        mail = mail_by_user_id(user_id)
        rendermail('/mail/event/event_notice.txt',
                   mail, name,
                   title=title,
                   link=link,
                   txt=txt,
                   notice_link=notice_link,
                  )

mq_notice_event_notice = mq_client(notice_event_notice)

def notice_event_kill_one(from_id, to_id, po_id):
    return notice_new(from_id, to_id, CID_NOTICE_EVENT_KILL, po_id)

def notice_event_kill_mail(user_id, title, link, txt, notice_link):
    name = Zsite.mc_get(user_id).name
    mail = mail_by_user_id(user_id)
    rendermail('/mail/event/event_notice.txt',
               mail, name,
               title=title,
               link=link,
               txt=txt,
               notice_link=notice_link,
              )
Beispiel #9
0
    kwds['sender_name'] = sender_name
    kwds['site_name'] = SITE_NAME
    kwds['site_domain'] = SITE_DOMAIN
    kwds['site_http'] = SITE_HTTP
    text = render_template(uri, **kwds)

    if subject is None:
        r = text.split('\n', 1)

        if len(r) < 2:
            r.append(r[0])

        if uri.endswith('.txt'):
            r[1] = r[1].replace('\n', '\n\n')

        subject = str(r[0])
        text = str(r[1])


#    print subject, '\n\n', text
#    return
    sendmail(subject, text, email, name, sender, sender_name, format)

from mq import mq_client
mq_rendermail = mq_client(rendermail)

if '__main__' == __name__:
    from time import time
    sendmail('time %s' % time(), '2345', '*****@*****.**')
    print SENDER_MAIL
Beispiel #10
0
def event_kill_extra(from_id, event_id, po_id):
    from notice import notice_event_kill_one, notice_event_kill_mail
    event_po = Po.mc_get(event_id)
    title = event_po.name
    event = Event.mc_get(event_id)
    link = event.link
    po = Po.mc_get(event_id)
    txt = po.name
    notice_link = po.link
    for i in EventJoiner.where(event_id=event_id).where('state>=%s', EVENT_JOIN_STATE_NEW):
        event_joiner_no(i)
        user_id = i.user_id
        notice_event_kill_one(from_id, user_id, po_id)
        notice_event_kill_mail(user_id, title, link, txt, notice_link)

mq_event_kill_extra = mq_client(event_kill_extra)

def event_kill(user_id, event, txt):
    from po_event import _po_event_notice_new
    if EVENT_STATE_RM < event.state < EVENT_STATE_END:
        event_id = event.id
        if event.can_change():
            po_rm(user_id, event_id)
        else:
            event.state = EVENT_STATE_RM
            event.save()
            zsite_id = event.zsite_id
            feed_rm(event_id)
            mc_flush_by_zsite_id(zsite_id)
            event_to_review_count_by_zsite_id.delete(user_id)
            mc_flush_by_user_id_event_id_owner_id(user_id, id, zsite_id)
Beispiel #11
0
        cid = pic.cid
        user_id = pic.user_id
        template = PIC_RM_TEMPLATE.get(cid)
        if template:
            user = Zsite.mc_get(user_id)
            name = user.name
            mail = mail_by_user_id(user_id)
            if cid == CID_ICO:
                if not ico.get(user_id):
                    rendermail(
                       template,
                       mail,
                       name,
                       user=user,
                    )



from mq import mq_client
mq_pic_rm_mail = mq_client(pic_rm_mail)

if __name__ == '__main__':
    #for i in  Pic.where(user_id=10005704):
        #print i.id, i.cid
    from ico import ico
    print ico.get(10000645)
    ico.set(10000645,788)



Beispiel #12
0
    event_po = Po.mc_get(event_id)
    title = event_po.name
    event = Event.mc_get(event_id)
    link = event.link
    po = Po.mc_get(event_id)
    txt = po.name
    notice_link = po.link
    for i in EventJoiner.where(event_id=event_id).where(
            'state>=%s', EVENT_JOIN_STATE_NEW):
        event_joiner_no(i)
        user_id = i.user_id
        notice_event_kill_one(from_id, user_id, po_id)
        notice_event_kill_mail(user_id, title, link, txt, notice_link)


mq_event_kill_extra = mq_client(event_kill_extra)


def event_kill(user_id, event, txt):
    from po_event import _po_event_notice_new
    if EVENT_STATE_RM < event.state < EVENT_STATE_END:
        event_id = event.id
        if event.can_change():
            po_rm(user_id, event_id)
        else:
            event.state = EVENT_STATE_RM
            event.save()
            zsite_id = event.zsite_id
            feed_rm(event_id)
            mc_flush_by_zsite_id(zsite_id)
            event_to_review_count_by_zsite_id.delete(user_id)