Fixed a minor bug where if you imported 2 OpenLP 2.0 databases in the same OpenLP session whose schemas were different, you'd get an error.

This commit is contained in:
Raoul Snyman 2011-12-04 22:50:13 +02:00
parent c825df38fa
commit 06570a9941

View File

@ -30,7 +30,7 @@ song databases into the current installation database.
"""
import logging
from sqlalchemy import create_engine, MetaData
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import class_mapper, mapper, relation, scoped_session, \
sessionmaker
from sqlalchemy.orm.exc import UnmappedClassError
@ -44,6 +44,28 @@ from songimport import SongImport
log = logging.getLogger(__name__)
class OpenLPSongImport(SongImport):
"""
The :class:`OpenLPSongImport` class provides OpenLP with the ability to
import song databases from other installations of OpenLP.
"""
def __init__(self, manager, **kwargs):
"""
Initialise the import.
``manager``
The song manager for the running OpenLP installation.
``source_db``
The database providing the data to import.
"""
SongImport.__init__(self, manager, **kwargs)
self.sourceSession = None
def doImport(self):
"""
Run the import for an OpenLP version 2 song database.
"""
class OldAuthor(BaseModel):
"""
Author model
@ -79,28 +101,6 @@ class OldTopic(BaseModel):
pass
class OpenLPSongImport(SongImport):
"""
The :class:`OpenLPSongImport` class provides OpenLP with the ability to
import song databases from other installations of OpenLP.
"""
def __init__(self, manager, **kwargs):
"""
Initialise the import.
``manager``
The song manager for the running OpenLP installation.
``source_db``
The database providing the data to import.
"""
SongImport.__init__(self, manager, **kwargs)
self.sourceSession = None
def doImport(self):
"""
Run the import for an OpenLP version 2 song database.
"""
if not self.importSource.endswith(u'.sqlite'):
self.logError(self.importSource,
translate('SongsPlugin.OpenLPSongImport',
@ -138,7 +138,7 @@ class OpenLPSongImport(SongImport):
secondary=source_songs_topics_table)
}
if has_media_files:
if source_media_files_songs_table is not None:
if isinstance(source_media_files_songs_table, Table):
song_props['media_files'] = relation(OldMediaFile,
backref='songs',
secondary=source_media_files_songs_table)