From cdceb3c3714af707bfe3ede10af6536eaf529ca8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 2 Apr 2007 21:36:11 +0000 Subject: - merged the "execcontext" branch, refactors engine/dialect codepaths - much more functionality moved into ExecutionContext, which impacted the API used by dialects to some degree - ResultProxy and subclasses now designed sanely - merged patch for #522, Unicode subclasses String directly, MSNVarchar implements for MS-SQL, removed MSUnicode. - String moves its "VARCHAR"/"TEXT" switchy thing into "get_search_list()" function, which VARCHAR and CHAR can override to not return TEXT in any case (didnt do the latter yet) - implements server side cursors for postgres, unit tests, #514 - includes overhaul of dbapi import strategy #480, all dbapi importing happens in dialect method "dbapi()", is only called inside of create_engine() for default and threadlocal strategies. Dialect subclasses have a datamember "dbapi" referencing the loaded module which may be None. - added "mock" engine strategy, doesnt require DBAPI module and gives you a "Connecition" which just sends all executes to a callable. can be used to create string output of create_all()/drop_all(). --- lib/sqlalchemy/pool.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/pool.py') diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 787fd059f..8d559aff5 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -237,7 +237,9 @@ class _ConnectionFairy(object): raise if self.__pool.echo: self.__pool.log("Connection %s checked out from pool" % repr(self.connection)) - + + _logger = property(lambda self: self.__pool.logger) + def invalidate(self): if self.connection is None: raise exceptions.InvalidRequestError("This connection is closed") @@ -248,7 +250,8 @@ class _ConnectionFairy(object): def cursor(self, *args, **kwargs): try: - return _CursorFairy(self, self.connection.cursor(*args, **kwargs)) + c = self.connection.cursor(*args, **kwargs) + return _CursorFairy(self, c) except Exception, e: self.invalidate() raise @@ -307,11 +310,14 @@ class _CursorFairy(object): def invalidate(self): self.__parent.invalidate() - + def close(self): if self in self.__parent._cursors: del self.__parent._cursors[self] - self.cursor.close() + try: + self.cursor.close() + except Exception, e: + self.__parent._logger.warn("Error closing cursor: " + str(e)) def __getattr__(self, key): return getattr(self.cursor, key) -- cgit v1.2.1