forked from openlp/openlp
Refactor BaseModel
bzr-revno: 829
This commit is contained in:
commit
9c2b6c0f96
@ -184,4 +184,5 @@ from songxmlhandler import SongXMLBuilder, SongXMLParser
|
|||||||
from themexmlhandler import ThemeXML
|
from themexmlhandler import ThemeXML
|
||||||
from renderer import Renderer
|
from renderer import Renderer
|
||||||
from rendermanager import RenderManager
|
from rendermanager import RenderManager
|
||||||
|
from basemodel import BaseModel
|
||||||
from baselistwithdnd import BaseListWithDnD
|
from baselistwithdnd import BaseListWithDnD
|
||||||
|
40
openlp/core/lib/basemodel.py
Normal file
40
openlp/core/lib/basemodel.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||||
|
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||||
|
# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin #
|
||||||
|
# Thompson, Jon Tibble, Carsten Tinggaard #
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# 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()
|
||||||
|
for key in kwargs:
|
||||||
|
me.__setattr__(key, kwargs[key])
|
||||||
|
return me
|
||||||
|
|
@ -30,7 +30,7 @@ import sqlite3
|
|||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import scoped_session, sessionmaker, mapper
|
from sqlalchemy.orm import scoped_session, sessionmaker, mapper
|
||||||
|
|
||||||
from openlp.core.lib import SettingsManager
|
from openlp.core.lib import BaseModel, SettingsManager
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.bibles.lib.models import *
|
from openlp.plugins.bibles.lib.models import *
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ from sqlalchemy import *
|
|||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
|
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
|
||||||
|
|
||||||
from openlp.core.lib import SettingsManager
|
from openlp.core.lib import BaseModel, SettingsManager
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation
|
||||||
from openlp.plugins.songs.lib.models import metadata, songs_table, Song, \
|
from openlp.plugins.songs.lib.models import metadata, songs_table, Song, \
|
||||||
Author, Topic, Book
|
Author, Topic, Book
|
||||||
|
@ -23,21 +23,7 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
class BaseModel(object):
|
from openlp.core.lib import BaseModel
|
||||||
"""
|
|
||||||
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 AlertItem(BaseModel):
|
class AlertItem(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
@ -27,20 +27,7 @@ from sqlalchemy import Column, Table, MetaData, ForeignKey, types, \
|
|||||||
create_engine
|
create_engine
|
||||||
from sqlalchemy.orm import mapper, relation, sessionmaker, scoped_session
|
from sqlalchemy.orm import mapper, relation, sessionmaker, scoped_session
|
||||||
|
|
||||||
class BaseModel(object):
|
from openlp.core.lib import BaseModel
|
||||||
"""
|
|
||||||
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 BibleMeta(BaseModel):
|
class BibleMeta(BaseModel):
|
||||||
|
@ -23,21 +23,7 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
class BaseModel(object):
|
from openlp.core.lib import BaseModel
|
||||||
"""
|
|
||||||
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 CustomSlide(BaseModel):
|
class CustomSlide(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
@ -23,21 +23,7 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
class BaseModel(object):
|
from openlp.core.lib import BaseModel
|
||||||
"""
|
|
||||||
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):
|
class Author(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
@ -23,21 +23,7 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
class BaseModel(object):
|
from openlp.core.lib import BaseModel
|
||||||
"""
|
|
||||||
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 SongUsageItem(BaseModel):
|
class SongUsageItem(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user