I have a booking class that uses associations to keep track of its staff, in order to keep track of what order they signed up in. So it's
booking_id, staff_id, ordering I also have a helper method on my booking class to set the associations from a list of ids, so that booking.set_id_staff_list( [1,2,3] ) should put staff 1,2,and 3 into the table in that order. This is working, but I also have various other windows open that might hold temp referrences to the booking. I was dealing with this problem by having my models update method call session.flush( [resource_obj] ) to only flush the object they had updated, and windows call session.expunge( resource_obj ) when they close to release referrences from the session. It seems to work for everything in the system until I add the associations. It appears to my untutored eye that maybe flushing just one object does not also flush just its referrences? After I save once the next time I get this: File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.3-py2.4.egg/sqlalchemy/orm/session.py", line 1076, in _update_impl raise exceptions.InvalidRequestError("Could not update instance '% s', identity key %s; a different instance with the same identity key already exists in this session." % (mapperutil.instance_str(instance), instance._instance_key)) sqlalchemy.exceptions.InvalidRequestError: Could not update instance '[EMAIL PROTECTED]', identity key (<class 'model_extern.Booking'>, (54L,), None); a different instance with the same identity key already exists in this session. The above doesn't happen if I replace session.flush( [resource_obj] ) with session.flush() and then session.clear(), but then I think I'm going to hit that same dangling ref problem again. If anyone has advice on how this sort of thing is properly handled or can point me at examples, that would be luverly! Thanks iain --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---