diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-09 17:35:24 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-09 17:35:24 -0500 |
| commit | a9b270a3ed4faf85f772897a867caf6762ff9160 (patch) | |
| tree | e6ea1d519fe6363c2c5a260faecc116b98b5ba19 /lib/sqlalchemy/events.py | |
| parent | f0157e24197649ce2e711c829414c29438870796 (diff) | |
| download | sqlalchemy-a9b270a3ed4faf85f772897a867caf6762ff9160.tar.gz | |
- basic docs
- poolevent accepts Engine as a target
Diffstat (limited to 'lib/sqlalchemy/events.py')
| -rw-r--r-- | lib/sqlalchemy/events.py | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/sqlalchemy/events.py b/lib/sqlalchemy/events.py index 55d5932af..355cf2235 100644 --- a/lib/sqlalchemy/events.py +++ b/lib/sqlalchemy/events.py @@ -13,16 +13,16 @@ class DDLEvents(event.Events): """ def on_before_create(self, target, connection, **kw): - pass + """ """ def on_after_create(self, target, connection, **kw): - pass + """ """ def on_before_drop(self, target, connection, **kw): - pass + """ """ def on_after_drop(self, target, connection, **kw): - pass + """ """ class PoolEvents(event.Events): @@ -41,8 +41,29 @@ class PoolEvents(event.Events): events.listen(my_on_checkout, 'on_checkout', Pool) + In addition to the :class:`.Pool` class and :class:`.Pool` instances, + :class:`.PoolEvents` also accepts :class:`.Engine` objects and + the :class:`.Engine` class as targets, which will be resolved + to the ``.pool`` attribute of the given engine or the :class:`.Pool` + class. + """ + @classmethod + def accept_with(cls, target): + from sqlalchemy.engine import Engine + from sqlalchemy.pool import Pool + + if isinstance(target, type): + if issubclass(target, Engine): + return Pool + elif issubclass(target, Pool): + return target + elif isinstance(target, Engine): + return target.pool + else: + return target + def on_connect(self, dbapi_connection, connection_record): """Called once for each new DB-API connection or Pool's ``creator()``. |
