]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Get rid of _wrap_db_error()
authorZane Bitter <zbitter@redhat.com>
Mon, 25 Jun 2012 13:03:17 +0000 (15:03 +0200)
committerZane Bitter <zbitter@redhat.com>
Thu, 28 Jun 2012 16:01:21 +0000 (18:01 +0200)
This was causing recursion depth errors, and the exceptions in question are
never being specifically caught anywhere anyway.

Fixes #137

Change-Id: Iebd2693bb1418392ebb041fbbb788bef28aae581
Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/db/sqlalchemy/session.py

index caa9fecaa5250b901c050b1a67b4bf6731246ade..dcdd6efbb12b1755edc5a23158c0c52f11637095 100644 (file)
@@ -27,30 +27,6 @@ _ENGINE = None
 _MAKER = None
 
 
-class Error(Exception):
-    pass
-
-
-class DBError(Error):
-    """Wraps an implementation specific exception."""
-    def __init__(self, inner_exception=None):
-        self.inner_exception = inner_exception
-        super(DBError, self).__init__(str(inner_exception))
-
-
-def _wrap_db_error(f):
-    def _wrap(*args, **kwargs):
-        try:
-            return f(*args, **kwargs)
-        except UnicodeEncodeError:
-            raise InvalidUnicodeParameter()
-        except Exception, e:
-            logger.exception(_('DB exception wrapped.'))
-            raise DBError(e)
-    _wrap.func_name = f.func_name
-    return _wrap
-
-
 def get_session(autocommit=True, expire_on_commit=False):
     """Return a SQLAlchemy session."""
     global _ENGINE, _MAKER
@@ -58,10 +34,7 @@ def get_session(autocommit=True, expire_on_commit=False):
     if _MAKER is None or _ENGINE is None:
         _ENGINE = get_engine()
         _MAKER = get_maker(_ENGINE, autocommit, expire_on_commit)
-    session = _MAKER()
-    session.query = _wrap_db_error(session.query)
-    session.flush = _wrap_db_error(session.flush)
-    return session
+    return _MAKER()
 
 
 class SynchronousSwitchListener(sqlalchemy.interfaces.PoolListener):