コード例 #1
0
ファイル: api.py プロジェクト: CottageLabs/localvoices
 def delete_version(cls, version_id):
     version = Version().get(version_id, links=True)
     
     if version is None:
         raise NotFoundException()
     
     # remove the version from storage first
     version.remove()
     
     # then remove the singer and re-index any related objects
     VersionIndex.delete_by_id(version.id)
コード例 #2
0
ファイル: api.py プロジェクト: CottageLabs/localvoices
 def create_version(cls, version_json, singer, song):
     if version_json is None:
         return None
     
     # create the version object and save it to the store
     version = Version({"version" : version_json})
     if singer is not None:
         version.singer = singer
     if song is not None:
         version.song = song
     version.save()
     
     # call the indexing process, and index this object and all
     # related ones
     VersionIndex.by_id(version.id, cascade=True)
     
     return version
コード例 #3
0
ファイル: api.py プロジェクト: CottageLabs/localvoices
 def update_version(cls, version_id, version_json=None, singer=None, song=None):
     # retrieve and update the version object in the desired way
     version = Version().get(version_id, links=True)
     
     if version is None:
         raise NotFoundException()
     
     if version_json is not None:
         version.patch_version(version_json, replace_all=True, keep_id=True)
     if singer is not None:
         version.singer = singer
     if song is not None:
         version.song = song
     version.save()
     
     # call the indexing process, and index this object and all related ones
     VersionIndex.by_id(version.id, cascade=True)
     
     return version
コード例 #4
0
ファイル: api.py プロジェクト: CottageLabs/localvoices
 def get_version(cls, version_id):
     version = VersionIndex.pull(version_id)
     if version is None:
         raise NotFoundException()
     return version.raw
コード例 #5
0
# connection object to use for the save operations
conn = esprit.raw.Connection(host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)

# index all the songs
#####################

for sid in song_ids:
    song = Song().get(sid, links=True, host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)
    si = SongIndex.from_song(song)
    si.save(conn=conn)

# index all the singers
#######################

for sid in singer_ids:
    singer = Singer().get(sid, links=True, host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)
    si = SingerIndex.from_singer(singer)
    si.save(conn=conn)

# index all the versions
########################

for vid in version_ids:
    version = Version().get(vid, links=True, host=settings.ELASTIC_SEARCH_HOST, index=settings.ELASTIC_SEARCH_DB)
    vi = VersionIndex.from_version(version)
    vi.save(conn=conn)