diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-01-02 01:29:38 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-01-02 01:29:38 +0000 |
| commit | a8b62a02ddc21d622c08ab0b05923fbe71eda36d (patch) | |
| tree | 019e7f88be4f0a7d30fc5dd2d870d07a09755ff4 /lib/sqlalchemy | |
| parent | 02a4176a657d54027703de5bbb4d4041ef271fe4 (diff) | |
| download | sqlalchemy-a8b62a02ddc21d622c08ab0b05923fbe71eda36d.tar.gz | |
- further fix to new TypeDecorator, so that subclasses of TypeDecorators work properly
- _handle_dbapi_exception() usage changed so that unwrapped exceptions can be rethrown with the original stack trace
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 24 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/default.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 4 | ||||
| -rw-r--r-- | lib/sqlalchemy/types.py | 4 |
4 files changed, 23 insertions, 15 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index e3433a06b..f2a1cd286 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -732,7 +732,8 @@ class Connection(Connectable): try: self.engine.dialect.do_begin(self.connection) except Exception, e: - raise self._handle_dbapi_exception(e, None, None, None) + self._handle_dbapi_exception(e, None, None, None) + raise def _rollback_impl(self): if not self.closed and not self.invalidated and self.__connection.is_valid: @@ -742,7 +743,8 @@ class Connection(Connectable): self.engine.dialect.do_rollback(self.connection) self.__transaction = None except Exception, e: - raise self._handle_dbapi_exception(e, None, None, None) + self._handle_dbapi_exception(e, None, None, None) + raise else: self.__transaction = None @@ -753,7 +755,8 @@ class Connection(Connectable): self.engine.dialect.do_commit(self.connection) self.__transaction = None except Exception, e: - raise self._handle_dbapi_exception(e, None, None, None) + self._handle_dbapi_exception(e, None, None, None) + raise def _savepoint_impl(self, name=None): if name is None: @@ -914,11 +917,11 @@ class Connection(Connectable): def _handle_dbapi_exception(self, e, statement, parameters, cursor): if getattr(self, '_reentrant_error', False): - return exceptions.DBAPIError.instance(None, None, e) + raise exceptions.DBAPIError.instance(None, None, e) self._reentrant_error = True try: if not isinstance(e, self.dialect.dbapi.Error): - return e + return is_disconnect = self.dialect.is_disconnect(e) if is_disconnect: self.invalidate(e) @@ -929,7 +932,7 @@ class Connection(Connectable): self._autorollback() if self.__close_with_result: self.close() - return exceptions.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) + raise exceptions.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) finally: del self._reentrant_error @@ -937,7 +940,8 @@ class Connection(Connectable): try: return self.engine.dialect.create_execution_context(connection=self, **kwargs) except Exception, e: - raise self._handle_dbapi_exception(e, kwargs.get('statement', None), kwargs.get('parameters', None), None) + self._handle_dbapi_exception(e, kwargs.get('statement', None), kwargs.get('parameters', None), None) + raise def _cursor_execute(self, cursor, statement, parameters, context=None): if self.engine._should_log_info: @@ -946,7 +950,8 @@ class Connection(Connectable): try: self.dialect.do_execute(cursor, statement, parameters, context=context) except Exception, e: - raise self._handle_dbapi_exception(e, statement, parameters, cursor) + self._handle_dbapi_exception(e, statement, parameters, cursor) + raise def _cursor_executemany(self, cursor, statement, parameters, context=None): if self.engine._should_log_info: @@ -955,7 +960,8 @@ class Connection(Connectable): try: self.dialect.do_executemany(cursor, statement, parameters, context=context) except Exception, e: - raise self._handle_dbapi_exception(e, statement, parameters, cursor) + self._handle_dbapi_exception(e, statement, parameters, cursor) + raise # poor man's multimethod/generic function thingy executors = { diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 16d55e5b8..e78eedd5c 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -337,7 +337,8 @@ class DefaultExecutionContext(base.ExecutionContext): try: self.cursor.setinputsizes(*inputsizes) except Exception, e: - raise self._connection._handle_dbapi_exception(e, None, None, None) + self._connection._handle_dbapi_exception(e, None, None, None) + raise else: inputsizes = {} for key in self.compiled.bind_names.values(): @@ -348,7 +349,8 @@ class DefaultExecutionContext(base.ExecutionContext): try: self.cursor.setinputsizes(**inputsizes) except Exception, e: - raise self._connection._handle_dbapi_exception(e, None, None, None) + self._connection._handle_dbapi_exception(e, None, None, None) + raise def __process_defaults(self): """generate default values for compiled insert/update statements, diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index cf6d14714..9e8b0f488 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -218,8 +218,8 @@ class DefaultCompiler(engine.Compiled): return pd else: return dict([(self.bind_names[bindparam], bindparam.value) for bindparam in self.bind_names]) - - params = property(lambda self:self.construct_params(), doc="""return a dictionary of bind parameter keys and values""") + + params = property(construct_params) def default_from(self): """Called when a SELECT statement has no froms, and no FROM clause is to be appended. diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 14262d6e0..5ab9ad450 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -239,7 +239,7 @@ class TypeDecorator(AbstractType): raise NotImplementedError() def bind_processor(self, dialect): - if 'process_bind_param' in self.__class__.__dict__: + if self.__class__.process_bind_param.func_code is not TypeDecorator.process_bind_param.func_code: impl_processor = self.impl.bind_processor(dialect) if impl_processor: def process(value): @@ -253,7 +253,7 @@ class TypeDecorator(AbstractType): return self.impl.bind_processor(dialect) def result_processor(self, dialect): - if 'process_result_value' in self.__class__.__dict__: + if self.__class__.process_result_value.func_code is not TypeDecorator.process_result_value.func_code: impl_processor = self.impl.result_processor(dialect) if impl_processor: def process(value): |
