From: Mike Bayer Date: Fri, 3 Feb 2006 01:15:06 +0000 (+0000) Subject: attempting to get MTOBackrefExtension to handle many-to-one, one-to-one equally X-Git-Tag: rel_0_1_0~74 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=47fac5873b02ec08f2a608d8c0cf8867996c795d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git attempting to get MTOBackrefExtension to handle many-to-one, one-to-one equally --- diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py index f2480918d4..87b09507f9 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):