Esempio n. 1
0
    def POST(self):
        params=web.input()
        cid=int(params.get('cid'))
        content=params.get('content')
        from_uid=int(params.get("from_uid",1))
        piclist=params.get('piclist','')
        if len(piclist):
            piclist=piclist.split(',')
        else:
            piclist=[]
        mid=None
        if params.get('mid'):
            mid=int(params.get('mid'))

        newpost=CirclePost()
        newpost.picture_list=piclist
        newpost.cid=cid
        newpost.uid=from_uid
        newpost.content=content
        newpost.mid=mid
        newpost.save()
        json_msg=DefJsonEncoder.encode(newpost.toJson())
        pusher.rawPush(body=json_msg,
                                            routing_key="sys.circle_new_board",headers={"type":"circle.newpost"})
        return DefJsonEncoder.encode({"postid":newpost.postid})
Esempio n. 2
0
def run(cid,content,pictures=[],mid=None):
    if isinstance(pictures,list)==False:
        pictures=[pictures]
    newpost=CirclePost()
    newpost.picture_list=pictures
    newpost.cid=cid
    newpost.uid=BackEndEnvData.uid
    newpost.content=content
    newpost.mid=mid
    newpost.save()
    json_msg=DefJsonEncoder.encode(newpost.toJson())
    BackEndEnvData.queue_producer.publish(body=json_msg,delivery_mode=2,
                                        routing_key="sys.circle_new_board",headers={"type":"circle.newpost"},
                                        compression='gzip')
    return Res({"postid":newpost.postid})