I see now, thanks! It's fairly difficult to plug in the events as you
suggested in my code, but I subclassed MappedCollection to discard setitem
calls with a None key, and used this as the collection class. This seems to
work, and if there's no other events I need to worry about during this
I created a class CorrelatedProxy inheriting from AssociationProxy that
allows the creator function to depend on the owner instance of the
association proxy. Essentially it gets a attribute 'correlator' of the
something like lambda x: lambda y, z: Constructor(x, y, z), and then
intercepts the
here's how you debug that:
@event.listens_for(A.ab, append)
def append(target, value, initiator):
import pdb
pdb.set_trace()
@event.listens_for(B.ab, append)
def append(target, value, initiator):
import pdb
pdb.set_trace()
and if you're concerned about attribute-access side