Based on some posts on the SQLAlchemy Google Group:
https://groups.google.com/forum/#!topic/sqlalchemy/S4_8PeRBNJw https://groups.google.com/forum/#!topic/sqlalchemy/YRy
sooo close ;-)
Please read Creation of New Values secion of association_proxy
extension.
In order to make your code work, you can either
Option-1: add the following constructor to UserImage
class:
def __init__(self, image):
self.image = image
or
Option-2: override the default creator
with your function:
images = association_proxy('_images', 'image',
creator=lambda _i: UserImage(image=_i),
)
I personally favor the latter.