I have a mapped class with a one to many relationship to another
class.
My need is that when a parent class is added to session automatically
it's populated with predefined children too.
I used to hook to `after-insert` event but now I read it's not
suitable for any Session.add (has it ever been like this or changed
recently?)
So, while it worked with sqlite, now I get no children at all in
mysql / postgresql
event.listen(UserStratigraphy, 'after_insert',
user_stratigraphy_after_insert)
def user_stratigraphy_after_insert(mapper, connection, user_strat):
for layer in DBSession.query(BaseLayer) \
.filter(BaseLayer.id_str==user_strat.id_str):
user_layer = UserLayer()
user_layer.user_stratigraphy = user_strat
user_layer.layer = layer
DBSession.add(user_layer)
What should be the best practice to avoid manually add all children
every time I instantiate a new parent?
Thanks for your support
neurino
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.