def create_singer(cls, singer_json, versions): if singer_json is None: return None # create the singer object and save it to the store singer = Singer({"singer" : singer_json}) if versions is not None: singer.versions = versions singer.save() # call the indexing process, and index this object and all # related ones SingerIndex.by_id(singer.id, cascade=True) return singer
def update_singer(cls, singer_id, singer_json=None, versions=None): # retrieve and update the singer object in the desired way singer = Singer().get(singer_id, links=True) if singer is None: raise NotFoundException() if singer_json is not None: singer.patch_singer(singer_json, replace_all=True, keep_id=True) if versions is not None: singer.versions = versions singer.save() # call the indexing process, and index this object and all related ones SingerIndex.by_id(singer.id, cascade=True) return singer