[sqlalchemy] Automatically populate a field in the association table when using attribute_mapped_collection association_proxy

2012-04-11 Thread Franck
Hi folks, I have a structure where a poll is associated with one vote per user, and each vote is associated with several results. To manipulate this as easily as possible I use attribute_mapped_collection and association_proxy - please see the attached file or here : http://pastebin.com/CR2PCbCZ

Re: [sqlalchemy] Automatically populate a field in the association table when using attribute_mapped_collection association_proxy

2012-04-11 Thread Michael Bayer
On Apr 11, 2012, at 7:45 AM, Franck wrote: Hi folks, I have a structure where a poll is associated with one vote per user, and each vote is associated with several results. To manipulate this as easily as possible I use attribute_mapped_collection and association_proxy - please see the

Re: [sqlalchemy] Automatically populate a field in the association table when using attribute_mapped_collection association_proxy

2012-04-11 Thread Franck
Hi Mike, Thanks for your prompt answer ! Thanks for fixing my default field - makes complete sense. Besides I added the vote_dt assignment in the PollVote constructor but it seems that this constructor is called only once, i.e. after the first result_values_by_user assignment :

Re: [sqlalchemy] Automatically populate a field in the association table when using attribute_mapped_collection association_proxy

2012-04-11 Thread Michael Bayer
On Apr 11, 2012, at 12:22 PM, Franck wrote: Hi Mike, Thanks for your prompt answer ! Thanks for fixing my default field - makes complete sense. Besides I added the vote_dt assignment in the PollVote constructor but it seems that this constructor is called only once, i.e. after the

Re: [sqlalchemy] Automatically populate a field in the association table when using attribute_mapped_collection association_proxy

2012-04-11 Thread Franck
Right ! Thanks *a lot* Mike, that's what I was trying to achieve. I think I don't need to listen to the set event since _AssociationSet does not support item assignment but it's a detail. Also, the attribute events don't intercept the creation of an initially empty set