Esempio n. 1
0
 def add_or_update(self, object):
     """
     
     Adds or updates the given object into the database depending
     if there already exists an object with same id or not.
     Used to merge object from the gui
     """
     
     result = self.__Session.merge(object)
     self.__Session.commit()
     print result.id
     import push
     push.add(result)
     return result
Esempio n. 2
0
def request(data, type, e_id):
    import push
    #import network.networkcomponent as networkcomponent
    """
    Does different things depending on the datatype-object
    """
    print 'request starts!'
    if (type == 'db_add_or_update'): #Updating database
        print 'type = db_add_or_update'
        db.add_or_update(data)
        push.add(data, e_id)
    
    elif (type == 'ping'):
        e_status = db.get_one_by_id(EmployeeStatus, e_id)
        print "Tagit emot pingpaket från employee-id: %s" % (e_status.e_id)
        e_status.online = True
        e_status.ip = data
        db.commit()
        db.add_or_update(e_status)