Example #1
0
def run(id):
    with dbconfig.Session() as session:
        conninfo=session.query(ConnectionInfo).filter(ConnectionInfo.connection_id==BackEndEnvData.connection_id).first()
        if conninfo is None:
            conninfo=ConnectionInfo()
        conninfo.client_id=int(id)
        conninfo.connection_id=BackEndEnvData.connection_id
        conninfo.queue_id=BackEndEnvData.reply_queue

        session.merge(conninfo)
        session.commit()
    return {"reged":id}
Example #2
0
def run(id):
    with dbconfig.Session() as session:
        conninfo = session.query(ConnectionInfo).filter(
            ConnectionInfo.connection_id ==
            BackEndEnvData.connection_id).first()
        if conninfo is None:
            conninfo = ConnectionInfo()
        conninfo.client_id = int(id)
        conninfo.connection_id = BackEndEnvData.connection_id
        conninfo.queue_id = BackEndEnvData.reply_queue

        session.merge(conninfo)
        session.commit()
    return {"reged": id}
Example #3
0
def run(sessionid):
    data = dbconfig.redisdb.get(str("session:%s" % sessionid))
    if data is None:
        return {"errno": 1, "error": "session not found", "result": {}}
    data = json.loads(data)
    with dbconfig.Session() as session:
        user_data = session.query(User).filter(User.uid == data["uid"]).first()
        if user_data:
            session.query(ConnectionInfo).filter(ConnectionInfo.connection_id == BackEndEnvData.connection_id).delete()
            session.commit()
            cinfo = session.query(ConnectionInfo).filter(ConnectionInfo.uid == user_data.uid).first()
            if cinfo is None:
                cinfo = ConnectionInfo()
                cinfo.uid = user_data.uid
            cinfo.connection_id = BackEndEnvData.connection_id
            cinfo.queue_id = BackEndEnvData.reply_queue
            session.merge(cinfo)
            session.commit()
        return {"errno": 0, "error": "no error", "result": user_data.toJson()}
Example #4
0
def run(sessionid):
    data = dbconfig.redisdb.get(str('session:%s' % sessionid))
    if data is None:
        return {"errno": 1, "error": "session not found", "result": {}}
    data = json.loads(data)
    with dbconfig.Session() as session:
        user_data = session.query(User).filter(User.uid == data['uid']).first()
        if user_data:
            session.query(ConnectionInfo).filter(
                ConnectionInfo.connection_id ==
                BackEndEnvData.connection_id).delete()
            session.commit()
            cinfo = session.query(ConnectionInfo).filter(
                ConnectionInfo.uid == user_data.uid).first()
            if cinfo is None:
                cinfo = ConnectionInfo()
                cinfo.uid = user_data.uid
            cinfo.connection_id = BackEndEnvData.connection_id
            cinfo.queue_id = BackEndEnvData.reply_queue
            session.merge(cinfo)
            session.commit()
        return {"errno": 0, "error": "no error", "result": user_data.toJson()}