def commit(self, db: DataBase): if db.find_obj(self) is None: self.__id = db.save_get_id(self) elif self.__is_changed: new_name = self.name if self.__new_name is None else self.__new_name new_country = self.country if self.__new_country is None else self.__new_country db.update(self, Recorder(new_name, new_country)) self.name, self.country = new_name, new_country self.__is_changed = False else: self.__id = db.get_id_obj(self)
def commit(self, db: DataBase): if db.find_obj(self) is None: self.__id = db.save_get_id(self) elif self.__is_changed: new_name = self.name if self.__new_name is None else self.__new_name new_soloists = self.soloists if self.soloists == self.__new_soloists else self.__new_soloists db.update(self, Author(new_name, new_soloists)) self.name, self.soloists = new_name, new_soloists self.__is_changed = False else: self.__id = db.get_id_obj(self) self.__new_soloists = []
def commit(self, db: DataBase): if db.find_obj(self) is None: self.__id = db.save_get_id(self) elif self.__is_changed: new_name_song = self.__new_name_song if self.__new_name_song is not None else self.name_song new_author = self.__new_author if self.__new_author is not None else self.author db.update(self, Song(new_name_song, new_author)) self.name_song = new_name_song self.author = new_author self.__is_changed = False else: self.__id = db.get_id_obj(self)
def commit(self, db: DataBase): if db.find_obj(self) is None: self.__id = db.save_get_id(self) elif self.__is_changed: new_name = self.__new_name if self.__new_name is not None else self.name new_year = self.__new_year if self.__new_year is not None else self.year new_recorder = self.__new_recorder if self.__new_recorder is not None else self.recorder new_songs = self.songs if self.songs == self.__new_songs else self.__new_songs new_types = self.types if self.types == self.__new_types else self.__new_types db.update( self, MediaProduct(new_name, new_types, new_recorder, new_year, new_songs)) self.name = new_name self.year = new_year self.recorder = new_recorder self.__types = new_types self.__songs = new_songs self.__is_changed = False else: self.__id = db.get_id_obj(self)