summaryrefslogtreecommitdiffstats
path: root/openstack/common/db/sqlalchemy/utils.py
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-02-04 16:40:01 +0000
committerMark McLoughlin <markmc@redhat.com>2013-02-07 15:25:29 -0500
commit06d1156248566322a7932dddfb833f46a8f573b8 (patch)
treeb3e6ac915b6b9fc2940815536d2ee0b12efe5e52 /openstack/common/db/sqlalchemy/utils.py
parent1575b00bb383b35d0251a5f74e67c1b18d61e51d (diff)
downloadoslo-06d1156248566322a7932dddfb833f46a8f573b8.tar.gz
oslo-06d1156248566322a7932dddfb833f46a8f573b8.tar.xz
oslo-06d1156248566322a7932dddfb833f46a8f573b8.zip
Remove openstack.common.db.common
Since this only contains exceptions that are either used in session.py or utils.py (not both), it seems sensible to move them into the modules where they are used. Also, remove the use of the Invalid base exception class since we don't seem to be making use of the base class anywhere by catching it rather than the more specialized exceptions. Change-Id: Ib05bb2e0a9494e1dc60c60b8eee0e76b5d2ee555
Diffstat (limited to 'openstack/common/db/sqlalchemy/utils.py')
-rw-r--r--openstack/common/db/sqlalchemy/utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/openstack/common/db/sqlalchemy/utils.py b/openstack/common/db/sqlalchemy/utils.py
index f7bb2f9..c8ab93e 100644
--- a/openstack/common/db/sqlalchemy/utils.py
+++ b/openstack/common/db/sqlalchemy/utils.py
@@ -22,7 +22,6 @@
import sqlalchemy
-from openstack.common.db import common as db_common
from openstack.common.gettextutils import _
from openstack.common import log as logging
@@ -30,6 +29,10 @@ from openstack.common import log as logging
LOG = logging.getLogger(__name__)
+class InvalidSortKey(Exception):
+ message = _("Sort key supplied was not valid.")
+
+
# copy from glance/db/sqlalchemy/api.py
def paginate_query(query, model, limit, sort_keys, marker=None,
sort_dir=None, sort_dirs=None):
@@ -90,7 +93,7 @@ def paginate_query(query, model, limit, sort_keys, marker=None,
try:
sort_key_attr = getattr(model, current_sort_key)
except AttributeError:
- raise db_common.InvalidSortKey()
+ raise InvalidSortKey()
query = query.order_by(sort_dir_func(sort_key_attr))
# Add pagination