From: Mike Bayer Date: Mon, 23 Apr 2007 19:53:34 +0000 (+0000) Subject: - big fix to AssociationProxy so that multiple AssociationProxy X-Git-Tag: rel_0_3_7~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7729164da37c58a2b56e80ab21b830264cd63e5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - big fix to AssociationProxy so that multiple AssociationProxy objects can be associated with a single association collection. --- diff --git a/CHANGES b/CHANGES index 76a7edda06..138277c130 100644 --- a/CHANGES +++ b/CHANGES @@ -100,7 +100,9 @@ - mysql - support for SSL arguments given as inline within URL query string, prefixed with "ssl_", courtesy terjeros@gmail.com. - +- extensions + - big fix to AssociationProxy so that multiple AssociationProxy + objects can be associated with a single association collection. 0.3.6 - sql: - bindparam() names are now repeatable! specify two diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 907ef19dcf..65b95ccbad 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -29,10 +29,11 @@ class AssociationProxy(object): ``__init__()`` constructor and setting the proxied attribute. """ + self.targetcollection = targetcollection self.attr = attr self.creator = creator - + def __init_deferred(self): prop = class_mapper(self._owner_class).props[self.targetcollection] self._cls = prop.mapper.class_ @@ -67,7 +68,7 @@ class AssociationProxy(object): self._owner_class = owner if obj is None: return self - storage_key = '_AssociationProxy_%s' % self.targetcollection + storage_key = '_AssociationProxy_%s_%s' % (self.targetcollection, self.attr) if self.uselist: try: return getattr(obj, storage_key)