Пример #1
0
def request(data, type):
    print 'request starts!'
    if (type == 'db_add_or_update'):
        print "type: db_add_or_update"
        db.add_or_update_no_push(data)
        gtk.gdk.threads_enter()
        gui.notify(data)
        gtk.gdk.threads_leave()
        
#    elif (type == 'textMessage'):
#        print "type: textMessage"
#        msg = TextMessage(data.src, data.dst, data.msg)
#        db.add_or_update(msg)
#        msg.src_object = db.get_one_by_id(Employee, msg.src)
#        msg.dst_object = db.get_one_by_id(Employee, msg.dst)
#        db.commit()
#        gtk.gdk.threads_enter()
#        gui.notify(msg)
#        gtk.gdk.threads_leave()

    elif (type == 'pong'):
        """
        Recieves a list with ID
        """
        
        print 'type: pong'
        onlineLista = data
        
        """
        Updates whos online in db
        """
        
        print 'dbupdate to false'
        for mongo in db.get_all(Employee):
            mongo.online=False
        
        print 'dbupdate to true from list'
        for id in onlineLista:
            user = db.get_one_by_id(Employee, id)
            user.online = True
        db.commit()
Пример #2
0
def add(object):
        print "PushAdd"
        row = QueueRow(object.__tablename__, object.id)
        db.add_or_update_no_push(row)
        print "Queuerow added to queue"
        q.put(row)