Even better, got rid of 'upgrade_schema' function which is not really needed.

This commit is contained in:
Raoul Snyman 2011-08-25 11:22:48 +02:00
parent 7e572cd0c2
commit 923261c59c
3 changed files with 9 additions and 17 deletions

View File

@ -142,7 +142,8 @@ class Manager(object):
""" """
Provide generic object persistence management Provide generic object persistence management
""" """
def __init__(self, plugin_name, init_schema, db_file_name=None, upgrade_schema=None): def __init__(self, plugin_name, init_schema, db_file_name=None,
upgrade_mod=None):
""" """
Runs the initialisation process that includes creating the connection Runs the initialisation process that includes creating the connection
to the database and the tables if they don't exist. to the database and the tables if they don't exist.
@ -181,8 +182,8 @@ class Manager(object):
unicode(settings.value(u'db hostname').toString()), unicode(settings.value(u'db hostname').toString()),
unicode(settings.value(u'db database').toString())) unicode(settings.value(u'db database').toString()))
settings.endGroup() settings.endGroup()
if upgrade_schema: if upgrade_mod:
upgrade_schema(self.db_url) upgrade_db(self.db_url, upgrade_mod)
self.session = init_schema(self.db_url) self.session = init_schema(self.db_url)
def save_object(self, object_instance, commit=True): def save_object(self, object_instance, commit=True):

View File

@ -32,8 +32,7 @@ the Songs plugin
from sqlalchemy import Column, ForeignKey, Table, types from sqlalchemy import Column, ForeignKey, Table, types
from sqlalchemy.orm import mapper, relation from sqlalchemy.orm import mapper, relation
from openlp.core.lib.db import BaseModel, init_db, upgrade_db from openlp.core.lib.db import BaseModel, init_db
from openlp.plugins.songs.lib import upgrade
class Author(BaseModel): class Author(BaseModel):
""" """
@ -71,15 +70,6 @@ class Topic(BaseModel):
""" """
pass pass
def upgrade_schema(url):
"""
Upgrades the songs database.
``url``
The database to upgrade
"""
upgrade_db(url, upgrade)
def init_schema(url): def init_schema(url):
""" """
Setup the songs database connection and initialise the database schema. Setup the songs database connection and initialise the database schema.

View File

@ -36,8 +36,9 @@ from openlp.core.lib import Plugin, StringContent, build_icon, translate, \
from openlp.core.lib.db import Manager from openlp.core.lib.db import Manager
from openlp.core.lib.ui import UiStrings, base_action, icon_action from openlp.core.lib.ui import UiStrings, base_action, icon_action
from openlp.core.utils.actions import ActionList from openlp.core.utils.actions import ActionList
from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
from openlp.plugins.songs.lib.db import init_schema, upgrade_schema, Song SongsTab
from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormat from openlp.plugins.songs.lib.importer import SongFormat
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
@ -58,7 +59,7 @@ class SongsPlugin(Plugin):
Create and set up the Songs plugin. Create and set up the Songs plugin.
""" """
Plugin.__init__(self, u'songs', plugin_helpers, SongMediaItem, SongsTab) Plugin.__init__(self, u'songs', plugin_helpers, SongMediaItem, SongsTab)
self.manager = Manager(u'songs', init_schema, upgrade_schema=upgrade_schema) self.manager = Manager(u'songs', init_schema, upgrade_mod=upgrade)
self.weight = -10 self.weight = -10
self.icon_path = u':/plugins/plugin_songs.png' self.icon_path = u':/plugins/plugin_songs.png'
self.icon = build_icon(self.icon_path) self.icon = build_icon(self.icon_path)