Fix various OpenLP 2 import problems.

bzr-revno: 1817
Fixes: https://launchpad.net/bugs/863845, https://launchpad.net/bugs/899532
This commit is contained in:
Raoul Snyman 2011-12-04 12:02:49 +02:00
commit f1c4367127

View File

@ -39,7 +39,7 @@ from openlp.core.lib import translate
from openlp.core.lib.db import BaseModel
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib import clean_song
from openlp.plugins.songs.lib.db import Author, Book, MediaFile, Song, Topic
from openlp.plugins.songs.lib.db import Author, Book, Song, Topic, MediaFile
from songimport import SongImport
log = logging.getLogger(__name__)
@ -121,6 +121,7 @@ class OpenLPSongImport(SongImport):
source_topics_table = source_meta.tables[u'topics']
source_authors_songs_table = source_meta.tables[u'authors_songs']
source_songs_topics_table = source_meta.tables[u'songs_topics']
source_media_files_songs_table = None
if has_media_files:
source_media_files_table = source_meta.tables[u'media_files']
source_media_files_songs_table = \
@ -137,13 +138,15 @@ class OpenLPSongImport(SongImport):
secondary=source_songs_topics_table)
}
if has_media_files:
if source_media_files_songs_table:
if source_media_files_songs_table is not None:
song_props['media_files'] = relation(OldMediaFile,
backref='songs',
secondary=source_media_files_songs_table)
else:
song_props['media_files'] = relation(OldMediaFile,
backref='songs')
backref='songs',
primaryjoin=source_songs_table.c.id == \
source_media_files_table.c.song_id)
try:
class_mapper(OldAuthor)
except UnmappedClassError: