summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-03-14 16:36:08 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-03-14 16:36:08 -0400
commit9337fb939e51f8b15c23c396a344e857321ff602 (patch)
tree273c73c18c0111bbf4d9bf6b0f9a65119b812ede /lib/sqlalchemy/schema.py
parent9ccfdaf1ae5e3b4bc5d8630f4a6d6e16c7db650c (diff)
downloadsqlalchemy-9337fb939e51f8b15c23c396a344e857321ff602.tar.gz
initial work on column reflect
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r--lib/sqlalchemy/schema.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index 68e8179f9..d1eb12f4f 100644
--- a/lib/sqlalchemy/schema.py
+++ b/lib/sqlalchemy/schema.py
@@ -141,6 +141,23 @@ class Table(SchemaItem, expression.TableClause):
:param info: A dictionary which defaults to ``{}``. A space to store
application specific data. This must be a dictionary.
+ :param listeners: A list of tuples of the form ``(<eventname>, <fn>)``
+ which will be passed to :func:`.event.listen` upon construction.
+ This alternate hook to :func:`.event.listen` allows the establishment
+ of a listener function specific to this :class:`.Table` before
+ the "autoload" process begins. Particularly useful for
+ the :meth:`.events.column_reflect` event::
+
+ def listen_for_reflect(table, column_info):
+ # ...
+
+ t = Table(
+ 'sometable',
+ autoload=True,
+ listeners=[
+ ('column_reflect', listen_for_reflect)
+ ])
+
:param mustexist: When ``True``, indicates that this Table must already
be present in the given :class:`MetaData`` collection.
@@ -240,6 +257,10 @@ class Table(SchemaItem, expression.TableClause):
self.quote_schema = kwargs.pop('quote_schema', None)
if 'info' in kwargs:
self.info = kwargs.pop('info')
+ if 'listeners' in kwargs:
+ listeners = kwargs.pop('listeners')
+ for evt, fn in listeners:
+ event.listen(self, evt, fn)
self._prefixes = kwargs.pop('prefixes', [])