forked from openlp/openlp
Trying to get around the problem of metadata not being bound to an engine.
bzr-revno: 289
This commit is contained in:
parent
4efdc4e274
commit
4071118398
@ -148,7 +148,7 @@
|
||||
</Others>
|
||||
<MainScript>openlp.pyw</MainScript>
|
||||
<Vcs>
|
||||
<VcsType>Subversion</VcsType>
|
||||
<VcsType>PySvn</VcsType>
|
||||
<VcsOptions>
|
||||
<dict>
|
||||
<key>
|
||||
@ -220,7 +220,7 @@
|
||||
</key>
|
||||
<value>
|
||||
<list>
|
||||
<string></string>
|
||||
<string></string>
|
||||
</list>
|
||||
</value>
|
||||
<key>
|
||||
|
33
openlp/plugins/songs/lib/meta.py
Normal file
33
openlp/plugins/songs/lib/meta.py
Normal file
@ -0,0 +1,33 @@
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
|
||||
__all__ = ['session', 'metadata', 'engine']
|
||||
|
||||
# SQLAlchemy database engine. Updated by model.init_model()
|
||||
engine = None
|
||||
|
||||
# SQLAlchemy session manager. Updated by model.init_model()
|
||||
session = None
|
||||
|
||||
# Global metadata. If you have multiple databases with overlapping table
|
||||
# names, you'll need a metadata for each database
|
||||
metadata = MetaData()
|
@ -20,22 +20,22 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
|
||||
|
||||
from openlp.plugins.songs.lib.meta import session, metadata, engine
|
||||
from openlp.plugins.songs.lib.tables import *
|
||||
from openlp.plugins.songs.lib.classes import *
|
||||
|
||||
session = None
|
||||
|
||||
def init_models(url):
|
||||
engine = create_engine(url)
|
||||
session = scoped_session(sessionmaker(autoflush=True, autocommit=False,
|
||||
bind=create_engine(url)))
|
||||
bind=engine))
|
||||
metadata.bind = engine
|
||||
|
||||
|
||||
#mapper(Author, authors_table)
|
||||
#mapper(Book, song_books_table)
|
||||
#mapper(Song, songs_table,
|
||||
# properties={'authors': relation(Author, backref='songs',
|
||||
# secondary=authors_songs_table),
|
||||
# 'book': relation(Book, backref='songs'),
|
||||
# 'topics': relation(Topic, backref='songs',
|
||||
# secondary=songs_topics_table)})
|
||||
#mapper(Topic, topics_table)
|
||||
mapper(Author, authors_table)
|
||||
mapper(Book, song_books_table)
|
||||
mapper(Song, songs_table,
|
||||
properties={'authors': relation(Author, backref='songs',
|
||||
secondary=authors_songs_table),
|
||||
'book': relation(Book, backref='songs'),
|
||||
'topics': relation(Topic, backref='songs',
|
||||
secondary=songs_topics_table)})
|
||||
mapper(Topic, topics_table)
|
||||
|
@ -17,9 +17,9 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, Table, MetaData, ForeignKey, types
|
||||
from sqlalchemy import Column, Table, ForeignKey, types
|
||||
|
||||
metadata = MetaData()
|
||||
from openlp.plugins.songs.lib.meta import metadata
|
||||
|
||||
# Definition of the "authors" table
|
||||
authors_table = Table('authors', metadata,
|
||||
|
Loading…
Reference in New Issue
Block a user