> > u.Xs is going to have exactly those X's which have u's id as their > user_id attribute. the X which you appended to u.Ys[0] is from a > different relationship. so yeah you have to set the user_id attribute > on the X, which is entirely legal. However the "legit" way to do it > is to just add the "X" to u's Xs collection and have the ORM take care > of the user_id attribute for you. just like: > > x = X() > u.Ys[0].Xs.append(x) > u.Xs.append(x)
Ah, I see, thanks. I hadn't thought of doing it that way since it sort of looks like it'd be inserting it twice. But, makes sense now that I see it. > no you dont need to do all that. even if you are just setting > "user_id" as you are now, just expire the attribute: > session.expire(u, ['Xs']), and it will reload when you touch it > again. but if you think in terms of collections instead of > foreign keys like above, then you dont even need that, it would just > all work out. Thanks again, I should have rtfm'd better for this one. scott --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---