forked from openlp/openlp
Added some SQLAlchemy models.
bzr-revno: 277
This commit is contained in:
parent
7d76349d3d
commit
14a9b67085
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
|
<!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
|
||||||
<!-- eric4 user project file for project openlp.org 2.0 -->
|
<!-- eric4 user project file for project openlp.org 2.0 -->
|
||||||
<!-- Saved: 2008-12-16, 23:58:55 -->
|
<!-- Saved: 2009-01-03, 01:14:22 -->
|
||||||
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
|
<!-- Copyright (C) 2009 Raoul Snyman, raoulsnyman@openlp.org -->
|
||||||
<UserProject version="4.0">
|
<UserProject version="4.0">
|
||||||
</UserProject>
|
</UserProject>
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
|
<!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
|
||||||
<!-- eric4 tasks file for project openlp.org 2.0 -->
|
<!-- eric4 tasks file for project openlp.org 2.0 -->
|
||||||
<!-- Saved: 2008-12-16, 23:58:55 -->
|
<!-- Saved: 2009-01-03, 01:14:23 -->
|
||||||
<Tasks version="4.2">
|
<Tasks version="4.2">
|
||||||
<Task priority="1" completed="False" bugfix="False">
|
<Task priority="1" completed="False" bugfix="False">
|
||||||
<Summary>TODO: what is the tags for bridge, pre-chorus?</Summary>
|
<Summary>TODO: what is the tags for bridge, pre-chorus?</Summary>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE Project SYSTEM "Project-4.4.dtd">
|
<!DOCTYPE Project SYSTEM "Project-4.4.dtd">
|
||||||
<!-- eric4 project file for project openlp.org 2.0 -->
|
<!-- eric4 project file for project openlp.org 2.0 -->
|
||||||
<!-- Saved: 2008-12-14, 21:47:18 -->
|
<!-- Saved: 2009-01-03, 01:14:22 -->
|
||||||
<!-- Copyright (C) 2008 Raoul Snyman, raoulsnyman@openlp.org -->
|
<!-- Copyright (C) 2009 Raoul Snyman, raoulsnyman@openlp.org -->
|
||||||
<Project version="4.4">
|
<Project version="4.4">
|
||||||
<ProgLanguage mixed="0">Python</ProgLanguage>
|
<ProgLanguage mixed="0">Python</ProgLanguage>
|
||||||
<ProjectType>Qt4</ProjectType>
|
<ProjectType>Qt4</ProjectType>
|
||||||
@ -95,11 +95,27 @@
|
|||||||
<Source>openlp/plugins/videos/videoplugin.py</Source>
|
<Source>openlp/plugins/videos/videoplugin.py</Source>
|
||||||
<Source>openlp/plugins/images/__init__.py</Source>
|
<Source>openlp/plugins/images/__init__.py</Source>
|
||||||
<Source>openlp/plugins/images/imageplugin.py</Source>
|
<Source>openlp/plugins/images/imageplugin.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/lib/songinterface.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/lib/songfile.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/forms/editsongdialog.py</Source>
|
||||||
|
<Source>openlp/core/lib/pluginutils.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/lib/songmanager.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/lib/songDBimpl.py</Source>
|
||||||
|
<Source>openlpcnv.pyw</Source>
|
||||||
|
<Source>openlp/plugins/songs/forms/songbookdialog.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/forms/topicsdialog.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/forms/authorsdialog.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/forms/topicsform.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/forms/authorsform.py</Source>
|
||||||
|
<Source>openlp/plugins/songs/forms/songbookform.py</Source>
|
||||||
|
<Source>openlp/migration/__init__.py</Source>
|
||||||
|
<Source>openlp/migration/migratefiles.py</Source>
|
||||||
|
<Source>openlp/migration/migratesongs.py</Source>
|
||||||
|
<Source>openlp/migration/display.py</Source>
|
||||||
|
<Source>openlp/migration/migratebibles.py</Source>
|
||||||
</Sources>
|
</Sources>
|
||||||
<Forms>
|
<Forms>
|
||||||
<Form>resources/forms/bibleimport.ui</Form>
|
|
||||||
<Form>resources/forms/openlpexportform.ui</Form>
|
<Form>resources/forms/openlpexportform.ui</Form>
|
||||||
<Form>resources/forms/editsongform.ui</Form>
|
|
||||||
<Form>resources/forms/opensongexportform.ui</Form>
|
<Form>resources/forms/opensongexportform.ui</Form>
|
||||||
<Form>resources/forms/about.ui</Form>
|
<Form>resources/forms/about.ui</Form>
|
||||||
<Form>resources/forms/settings.ui</Form>
|
<Form>resources/forms/settings.ui</Form>
|
||||||
@ -111,6 +127,11 @@
|
|||||||
<Form>resources/forms/openlpimportform.ui</Form>
|
<Form>resources/forms/openlpimportform.ui</Form>
|
||||||
<Form>resources/forms/splashscreen.ui</Form>
|
<Form>resources/forms/splashscreen.ui</Form>
|
||||||
<Form>resources/forms/bibleimportprogress.ui</Form>
|
<Form>resources/forms/bibleimportprogress.ui</Form>
|
||||||
|
<Form>resources/forms/authorsdialog.ui</Form>
|
||||||
|
<Form>resources/forms/bibleimportdialog.ui</Form>
|
||||||
|
<Form>resources/forms/songbookdialog.ui</Form>
|
||||||
|
<Form>resources/forms/topicsdialog.ui</Form>
|
||||||
|
<Form>resources/forms/editsongdialog.ui</Form>
|
||||||
</Forms>
|
</Forms>
|
||||||
<Translations>
|
<Translations>
|
||||||
</Translations>
|
</Translations>
|
||||||
|
58
openlp/plugins/songs/lib/classes.py
Normal file
58
openlp/plugins/songs/lib/classes.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# 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
|
||||||
|
"""
|
||||||
|
|
||||||
|
class BaseModel(object):
|
||||||
|
"""
|
||||||
|
BaseModel provides a base object with a set of generic functions
|
||||||
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def populate(cls, **kwargs):
|
||||||
|
"""
|
||||||
|
Creates an instance of a class and populates it, returning the instance
|
||||||
|
"""
|
||||||
|
me = cls()
|
||||||
|
keys = kwargs.keys()
|
||||||
|
for key in keys:
|
||||||
|
me.__setattr__(key, kwargs[key])
|
||||||
|
return me
|
||||||
|
|
||||||
|
class Author(BaseModel):
|
||||||
|
"""
|
||||||
|
Author model
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Book(BaseModel):
|
||||||
|
"""
|
||||||
|
Book model
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Song(BaseModel):
|
||||||
|
"""
|
||||||
|
Song model
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Topic(BaseModel):
|
||||||
|
"""
|
||||||
|
Topic model
|
||||||
|
"""
|
||||||
|
pass
|
41
openlp/plugins/songs/lib/models.py
Normal file
41
openlp/plugins/songs/lib/models.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# 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 create_engine
|
||||||
|
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
|
||||||
|
|
||||||
|
from openlp.plugins.songs.lib.tables import *
|
||||||
|
from openlp.plugins.songs.lib.classes import *
|
||||||
|
|
||||||
|
Session = None
|
||||||
|
|
||||||
|
def init_models(url):
|
||||||
|
Session = scoped_session(sessionmaker(autoflush=True, autocommit=False,
|
||||||
|
bind=create_engine(url)))
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
71
openlp/plugins/songs/lib/tables.py
Normal file
71
openlp/plugins/songs/lib/tables.py
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# 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 Column, Table, MetaData, ForeignKey, types
|
||||||
|
|
||||||
|
metadata = MetaData()
|
||||||
|
|
||||||
|
# Definition of the "authors" table
|
||||||
|
authors_table = Table('authors', metadata,
|
||||||
|
Column('id', types.Integer, primary_key=True),
|
||||||
|
Column('first_name', types.Unicode(128)),
|
||||||
|
Column('last_name', types.Unicode(128)),
|
||||||
|
Column('display_name', types.Unicode(255), nullable=False)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Definition of the "song_books" table
|
||||||
|
song_books_table = Table('song_books', metadata,
|
||||||
|
Column('id', types.Integer, primary_key=True),
|
||||||
|
Column('name', types.Unicode(128), nullable=False),
|
||||||
|
Column('publisher', types.Unicode(128))
|
||||||
|
)
|
||||||
|
|
||||||
|
# Definition of the "songs" table
|
||||||
|
songs_table = Table('songs', metadata,
|
||||||
|
Column('id', types.Integer(), primary_key=True),
|
||||||
|
Column('song_book_id', types.Integer, ForeignKey('song_books.id'), default=0),
|
||||||
|
Column('title', types.Unicode(255), nullable=False),
|
||||||
|
Column('lyrics', types.UnicodeText, nullable=False),
|
||||||
|
Column('verse_order', types.Unicode(128)),
|
||||||
|
Column('copyright', types.Unicode(255)),
|
||||||
|
Column('comments', types.UnicodeText),
|
||||||
|
Column('ccli_number', types.Unicode(64)),
|
||||||
|
Column('song_number', types.Unicode(64)),
|
||||||
|
Column('theme_name', types.Unicode(128)),
|
||||||
|
Column('search_title', types.Unicode(255), index=True, nullable=False),
|
||||||
|
Column('search_lyrics', types.UnicodeText, index=True, nullable=False)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Definition of the "topics" table
|
||||||
|
topics_table = Table('topics', metadata,
|
||||||
|
Column('id', types.Integer, primary_key=True),
|
||||||
|
Column('name', types.Unicode(128), nullable=False)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Definition of the "authors_songs" table
|
||||||
|
authors_songs_table = Table('authors_songs', metadata,
|
||||||
|
Column('author_id', types.Integer, ForeignKey('authors.id'), primary_key=True),
|
||||||
|
Column('song_id', types.Integer, ForeignKey('songs.id'), primary_key=True)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Definition of the "songs_topics" table
|
||||||
|
songs_topics_table = Table('songs_topics', metadata,
|
||||||
|
Column('song_id', types.Integer, ForeignKey('songs.id'), primary_key=True),
|
||||||
|
Column('topic_id', types.Integer, ForeignKey('topics.id'), primary_key=True)
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user