summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Windisch <eric@cloudscaling.com>2012-12-04 10:40:10 -0500
committerMark McLoughlin <markmc@redhat.com>2013-02-05 10:50:12 +0000
commit916c243678af9c2943da213ba63d542f56329dc4 (patch)
treed2dabaabe3498662631eb3c6c983343fcd8fd43f
parent00adcb1ca6becbdc564f46ff9975a23a83a140ec (diff)
downloadpbr-916c243678af9c2943da213ba63d542f56329dc4.tar.gz
Import sqlalchemy session/models/utils
Bring in session, base model, utilities, and tests for sqlalchemy from Nova. Add sqlalchemy to pip-requires and and python-mysql to test-requires. Partially implements blueprint common-db Change-Id: I3e0065cdac87e10c4e0742d66c293c72bb3acbb2
-rw-r--r--db/common.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/db/common.py b/db/common.py
new file mode 100644
index 0000000..8f6968f
--- /dev/null
+++ b/db/common.py
@@ -0,0 +1,44 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+# Copyright 2012 Cloudscaling Group, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from openstack.common.gettextutils import _
+from openstack.common import log as logging
+
+
+LOG = logging.getLogger(__name__)
+
+
+class Invalid(Exception):
+ pass
+
+
+class InvalidSortKey(Invalid):
+ message = _("Sort key supplied was not valid.")
+
+
+class InvalidUnicodeParameter(Invalid):
+ message = _("Invalid Parameter: "
+ "Unicode is not supported by the current database.")
+
+
+class DBError(Exception):
+ """Wraps an implementation specific exception."""
+ def __init__(self, inner_exception=None):
+ self.inner_exception = inner_exception
+ super(DBError, self).__init__(str(inner_exception))