DB cleanups

This commit is contained in:
Jon Tibble 2010-07-01 11:31:37 +01:00
parent 079d72f93f
commit c61121bb51
2 changed files with 7 additions and 6 deletions

View File

@ -188,9 +188,10 @@ class Manager(object):
``order_by_ref``
Any parameters to order the returned objects by. Defaults to None.
"""
query = self.session.query(object_class)
if order_by_ref:
return self.session.query(object_class).order_by(order_by_ref).all()
return self.session.query(object_class).all()
return query.order_by(order_by_ref).all()
return query.all()
def get_all_objects_filtered(self, object_class, filter_clause,
order_by_ref=None):
@ -206,10 +207,10 @@ class Manager(object):
``order_by_ref``
Any parameters to order the returned objects by. Defaults to None.
"""
query = self.session.query(object_class).filter(filter_clause)
if order_by_ref:
return self.session.query(object_class).filter(filter_clause) \
.order_by(order_by_ref).all()
return self.session.query(object_class).filter(filter_clause).all()
return query.order_by(order_by_ref).all()
return query.all()
def delete_object(self, object_class, key):
"""

View File

@ -31,7 +31,7 @@ from openlp.core.lib import Plugin, build_icon, PluginStatus, Receiver, \
translate
from openlp.core.lib.db import Manager
from openlp.plugins.songs.lib import SongMediaItem, SongsTab
from openlp.plugins.songs.lib.db import Song
from openlp.plugins.songs.lib.db import init_schema, Song
try:
from openlp.plugins.songs.lib import SofImport, OooImport