Hi everyone, I'm stuck going around in circles here so any help would be great. I don't know whether I should be using transactions or not to solve this, but haven't got it working yet with either flushes or commits.
Problem: - a gui app manages two resources, bookings and clients - bookings have clients, as a relation, working - when a form is opened to create a new booking or client, it creates a new one in the session - if the user saves, this resource object ref is passed to a model that updates the db and fires listeners - in that case, the ref needs to be flushed/committed - if the user cancels after opening a form, the form destructor calls the model to expunge the resource object with session.expunge(resource_obj) ( working ok ) My problem is when a new booking is created, and a new client is going to be created too: - booking form opens, makes new 'on-deck' booking ref - client sub form is opened, makes new 'on-deck' client ref - client form is saved, problem is how to flush *only* the new client while still keeping the on-deck booking 'on-deck' I've tried various combinations but am certainly in over my head so if anyone has recommend procedures I would love to hear them. I know that autoflush is out because the bookings cannot be flushed until they have a valid client ( on purpose, good! ). Flushing just one object at a time seemed to be a possibility, but I get this traceback when trying that out on saving an already existing booking attached to an existing client: (log output) - setting attribute size to 22 - attempting session.flush(( 2008-04-12 - 14:00:00 - BS Sec - 22 people - <Client 18282 : Armstrong, Neil> )) (traceback) Traceback (most recent call last): File "/home/xornot/www/booking/booking-wx/form_builder.py", line 385, in onSave self.model.update_resource_obj('edit', self.resource_obj, result['valid_values']) File "/home/xornot/www/booking/booking-wx/model.py", line 227, in update_resource_obj session.flush(resource_obj) File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.3-py2.4.egg/sqlalchemy/orm/session.py", line 764, in flush self.uow.flush(self, objects) File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.4.3-py2.4.egg/sqlalchemy/orm/unitofwork.py", line 189, in flush objset = util.Set([o._state for o in objects]) TypeError: iteration over non-sequence Any input welcome! 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 -~----------~----~----~----~------~----~------~--~---