diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-24 17:55:06 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-24 17:55:06 -0400 |
commit | 693e2dcacf7c6317c131ad11fcc0466e6c9164b8 (patch) | |
tree | f807bae733831f9b09fc59447b8ffabd022d7a66 /lib/sqlalchemy/interfaces.py | |
parent | 8a7ae371535342bb35491d59aaa1131ba7c435fa (diff) | |
download | sqlalchemy-693e2dcacf7c6317c131ad11fcc0466e6c9164b8.tar.gz |
- worked it out so that classes declare a nested class "event",
with methods representing events. This is self-documenting via sphinx.
- implemented new model for pool, classmanager. Most events are
one or two args, so going back to allowing any kind of *arg, **kw
signature for events - this is simpler and improves performance,
though we don't get the "we can add new kw's anytime". perhaps
there's some other way to approach that.
Diffstat (limited to 'lib/sqlalchemy/interfaces.py')
-rw-r--r-- | lib/sqlalchemy/interfaces.py | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/sqlalchemy/interfaces.py b/lib/sqlalchemy/interfaces.py index 2447b15bf..c7f3a1109 100644 --- a/lib/sqlalchemy/interfaces.py +++ b/lib/sqlalchemy/interfaces.py @@ -6,13 +6,15 @@ """Interfaces and abstract types.""" -from sqlalchemy.util import as_interface, adapt_kw_to_positional +from sqlalchemy.util import as_interface +from sqlalchemy import event class PoolListener(object): """Hooks into the lifecycle of connections in a :class:`Pool`. .. note:: :class:`PoolListener` is deprecated. Please - refer to :func:`event.listen`. + refer to :func:`event.listen` as well as + :attr:`Pool.events`. Usage:: @@ -65,27 +67,21 @@ class PoolListener(object): @classmethod def _adapt_listener(cls, self, listener): - """Adapt a :class:`PoolListener` to individual + """Adapt a :class:`PoolListener` to individual :class:`event.Dispatch` events. """ - listener = as_interface(listener, - methods=('connect', 'first_connect', 'checkout', 'checkin')) + listener = as_interface(listener, methods=('connect', + 'first_connect', 'checkout', 'checkin')) if hasattr(listener, 'connect'): - self._dispatch.append('on_connect', - adapt_kw_to_positional(listener.connect, - 'dbapi_con', 'con_record'), - self) + event.listen(listener.connect, 'on_connect', self) if hasattr(listener, 'first_connect'): - self._dispatch.append('on_first_connect', - adapt_kw_to_positional(listener.first_connect, - 'dbapi_con', 'con_record'), - self) + event.listen(listener.first_connect, 'on_first_connect', self) if hasattr(listener, 'checkout'): - self._dispatch.append('on_checkout', listener.checkout, self) + event.listen(listener.checkout, 'on_checkout', self) if hasattr(listener, 'checkin'): - self._dispatch.append('on_checkin', listener.checkin, self) + event.listen(listener.checkin, 'on_checkin', self) def connect(self, dbapi_con, con_record): |