From 586e5be1bb2bedb69802312925ca84f81199f2ff Mon Sep 17 00:00:00 2001 From: Jason Kirtland Date: Mon, 5 May 2008 21:33:29 +0000 Subject: Adjusted inplace-binops on set-based collections and association proxies to more closely follow builtin (2.4+) set semantics. Formerly any set duck-type was accepted, now only types or subtypes of set, frozenset or the collection type itself are accepted. --- lib/sqlalchemy/ext/associationproxy.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/sqlalchemy/ext') diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index bcbfb4780..d878f7b9b 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -6,10 +6,12 @@ transparent proxied access to the endpoint of an association object. See the example ``examples/association/proxied_association.py``. """ -import weakref, itertools -import sqlalchemy.exceptions as exceptions -import sqlalchemy.orm as orm -import sqlalchemy.util as util +import itertools +import weakref +from sqlalchemy import exceptions +from sqlalchemy import orm +from sqlalchemy import util +from sqlalchemy.orm import collections def association_proxy(targetcollection, attr, **kw): @@ -702,7 +704,7 @@ class _AssociationSet(object): self.add(value) def __ior__(self, other): - if util.duck_type_collection(other) is not util.Set: + if not collections._set_binops_check_strict(self, other): return NotImplemented for value in other: self.add(value) @@ -726,7 +728,7 @@ class _AssociationSet(object): self.discard(value) def __isub__(self, other): - if util.duck_type_collection(other) is not util.Set: + if not collections._set_binops_check_strict(self, other): return NotImplemented for value in other: self.discard(value) @@ -748,7 +750,7 @@ class _AssociationSet(object): self.add(value) def __iand__(self, other): - if util.duck_type_collection(other) is not util.Set: + if not collections._set_binops_check_strict(self, other): return NotImplemented want, have = self.intersection(other), util.Set(self) @@ -776,7 +778,7 @@ class _AssociationSet(object): self.add(value) def __ixor__(self, other): - if util.duck_type_collection(other) is not util.Set: + if not collections._set_binops_check_strict(self, other): return NotImplemented want, have = self.symmetric_difference(other), util.Set(self) -- cgit v1.2.1