def save(entity): if entity.key is None: entity = Driver.save(entity) else: current = Driver.get(entity.key) if current is not None: # current.driver_phone = entity.driver_phone # current.driver_email = entity.driver_email # current.driver_id = entity.driver_id # current.driver_operational = entity.driver_operational # current.driver_name = entity.driver_name entity = Driver.save(entity) else: raise ValueError("Driver does not exists") return entity
def update_component(servers=None, type=None, name=None, vendor=None, comments=None, hw_id=None, driver=None): component = get(c for c in Component if c.name == name) if servers: servers = select(s for s in Server if s.name in servers)[:] component.servers.clear() for s in servers: component.servers.add(s) if type is not None and check_type(type): component.type = type if name is not None: component.name = name if vendor is not None: component.vendor = vendor if comments is not None: component.comments = comments if hw_id is not None: component.hw_id = hw_id if driver is not None: driver = Driver.get(lambda d: d.name == driver) if driver is not None: component.driver = driver return component
def delete(id): entity = Driver.get(id) if (entity is None): raise ValueError("Driver does not exists") else: entity.key.delete()
def get(id): return Driver.get(id)