diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-02-03 01:15:06 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-02-03 01:15:06 +0000 |
commit | 47fac5873b02ec08f2a608d8c0cf8867996c795d (patch) | |
tree | d51a0a25969512338d2379c32f4957da2b2a1cff /lib/sqlalchemy/attributes.py | |
parent | 38eea593ed64fa848aa903c26c46f8ac0d78c007 (diff) | |
download | sqlalchemy-47fac5873b02ec08f2a608d8c0cf8867996c795d.tar.gz |
attempting to get MTOBackrefExtension to handle many-to-one, one-to-one equally
Diffstat (limited to 'lib/sqlalchemy/attributes.py')
-rw-r--r-- | lib/sqlalchemy/attributes.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py index f2480918d..87b09507f 100644 --- a/lib/sqlalchemy/attributes.py +++ b/lib/sqlalchemy/attributes.py @@ -89,6 +89,10 @@ class PropHistory(object): self.obj.__dict__[self.key] = None if self.extension is not None: self.extension.set(self.obj, None, self.orig) + def append(self, obj): + self.setattr(obj) + def remove(self, obj): + self.delattr() def rollback(self): if self.orig is not PropHistory.NONE: self.obj.__dict__[self.key] = self.orig @@ -242,9 +246,12 @@ class MTOBackrefExtension(AttributeExtension): self.key = key def set(self, obj, child, oldchild): if oldchild is not None: - getattr(oldchild, self.key).remove(obj) + prop = oldchild.__class__._attribute_manager.get_history(oldchild, self.key) + prop.remove(obj) if child is not None: - getattr(child, self.key).append(obj) + prop = child.__class__._attribute_manager.get_history(child, self.key) + prop.append(obj) + class AttributeManager(object): """maintains a set of per-attribute history container objects for a set of objects.""" def __init__(self): |