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
"""
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
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 database').toString()))
settings.endGroup()
if upgrade_schema:
upgrade_schema(self.db_url)
if upgrade_mod:
upgrade_db(self.db_url, upgrade_mod)
self.session = init_schema(self.db_url)
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.orm import mapper, relation
from openlp.core.lib.db import BaseModel, init_db, upgrade_db
from openlp.plugins.songs.lib import upgrade
from openlp.core.lib.db import BaseModel, init_db
class Author(BaseModel):
"""
@ -71,15 +70,6 @@ class Topic(BaseModel):
"""
pass
def upgrade_schema(url):
"""
Upgrades the songs database.
``url``
The database to upgrade
"""
upgrade_db(url, upgrade)
def init_schema(url):
"""
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.ui import UiStrings, base_action, icon_action
from openlp.core.utils.actions import ActionList
from openlp.plugins.songs.lib import clean_song, SongMediaItem, SongsTab
from openlp.plugins.songs.lib.db import init_schema, upgrade_schema, Song
from openlp.plugins.songs.lib import clean_song, upgrade, SongMediaItem, \
SongsTab
from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormat
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
@ -58,7 +59,7 @@ class SongsPlugin(Plugin):
Create and set up the Songs plugin.
"""
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.icon_path = u':/plugins/plugin_songs.png'
self.icon = build_icon(self.icon_path)