Contain the AssociationProxy class.
The AssociationProxy is a Python property object which provides transparent proxied access to the endpoint of an association object.
See the example examples/association/proxied_association.py.
Convenience function for use in mapped classes. Implements a Python property representing a relation as a collection of simpler values. The proxied property will mimic the collection type of the target (list, dict or set), or in the case of a one to one relation, a simple scalar value.
Attribute on the associated instances we'll proxy for. For example, given a target collection of [obj1, obj2], a list created by this proxy property would look like [getattr(obj1, attr), getattr(obj2, attr)]
If the relation is one-to-one or otherwise uselist=False, then simply: getattr(obj, attr)
When new items are added to this proxied collection, new instances of the class collected by the target collection will be created. For list and set collections, the target class constructor will be called with the 'value' for the new instance. For dict types, two arguments are passed: key and value.
If you want to construct instances differently, supply a 'creator' function that takes arguments as above and returns instances.
For scalar relations, creator() will be called if the target is None. If the target is present, set operations are proxied to setattr() on the associated object.
If you have an associated object with multiple attributes, you may set up multiple association proxies mapping to different attributes. See the unit tests for examples, and for examples of how creator() functions can be used to construct the scalar relation on-demand in this situation.
Passes along any other arguments to AssociationProxy
A property object that automatically sets up AssociationLists on an object.
Arguments are:
Optional. When new items are added to this proxied collection, new instances of the class collected by the target collection will be created. For list and set collections, the target class constructor will be called with the 'value' for the new instance. For dict types, two arguments are passed: key and value.
If you want to construct instances differently, supply a 'creator' function that takes arguments as above and returns instances.