def create_song(cls, song_json, versions, songs): if song_json is None: return None # create the song object and save it to the store song = Song({"song" : song_json}) if versions is not None: song.versions = versions if songs is not None: song.songs = songs song.save() # call the indexing process, and index this object and all # related ones SongIndex.by_id(song.id, cascade=True) return song
def update_song(cls, song_id, song_json=None, versions=None, songs=None): # retrieve and update the song object in the desired way song = Song().get(song_id, links=True) if song is None: raise NotFoundException() if song_json is not None: song.patch_song(song_json, replace_all=True, keep_id=True) if versions is not None: song.versions = versions if songs is not None: song.songs = songs song.save() # call the indexing process, and index this object and all related ones print song.id SongIndex.by_id(song.id, cascade=True) return song