summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/event.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-01-30 20:29:48 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-01-30 20:29:48 -0500
commit12073e281eebdece0fe4e24c6704d57eafdc9247 (patch)
tree1c831d73551c5a2e490bae41af390bd44d6391b5 /lib/sqlalchemy/event.py
parent41d222b5f85d81c3cb7c33be284b9b5507463cb2 (diff)
downloadsqlalchemy-12073e281eebdece0fe4e24c6704d57eafdc9247.tar.gz
- SchemaItem, SchemaType now descend from common type
SchemaEventTarget, which supplies dispatch - the dispatch now provides before_parent_attach(), after_parent_attach(), events which generally bound the _set_parent() event. [ticket:2037] - the _on_table_attach mechanism now usually uses the event dispatch - fixed class-level event dispatch to propagate to all subclasses, not just immediate subclasses - fixed class-level event unpickling to handle more involved inheritance hierarchies, needed by the new schema event dispatch. - ForeignKeyConstraint doesn't re-call the column attach event on ForeignKey objects that are already associated with the correct Column - we still need that ImportError on mysqldb CLIENT FLAGS to support mock DBAPIs
Diffstat (limited to 'lib/sqlalchemy/event.py')
-rw-r--r--lib/sqlalchemy/event.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/sqlalchemy/event.py b/lib/sqlalchemy/event.py
index 66b7e2d1b..0fcc8ef49 100644
--- a/lib/sqlalchemy/event.py
+++ b/lib/sqlalchemy/event.py
@@ -48,7 +48,11 @@ class _UnpickleDispatch(object):
"""
def __call__(self, _parent_cls):
- return _parent_cls.__dict__['dispatch'].dispatch_cls(_parent_cls)
+ for cls in _parent_cls.__mro__:
+ if 'dispatch' in cls.__dict__:
+ return cls.__dict__['dispatch'].dispatch_cls(_parent_cls)
+ else:
+ raise AttributeError("No class with a 'dispatch' member present.")
class _Dispatch(object):
"""Mirror the event listening definitions of an Events class with
@@ -167,11 +171,17 @@ class _DispatchDescriptor(object):
assert isinstance(target, type), \
"Class-level Event targets must be classes."
- for cls in [target] + target.__subclasses__():
+ stack = [target]
+ while stack:
+ cls = stack.pop(0)
+ stack.extend(cls.__subclasses__())
self._clslevel[cls].append(obj)
def remove(self, obj, target):
- for cls in [target] + target.__subclasses__():
+ stack = [target]
+ while stack:
+ cls = stack.pop(0)
+ stack.extend(cls.__subclasses__())
self._clslevel[cls].remove(obj)
def clear(self):