you can't do Session operations and commits inside of after_insert(). you're already in the session.flush() operation. I guess I have to make this clearer for every individual method in the docs.
grassoalvaro wrote: > > I don't know why but now exception is: > > InvalidRequestError: Instance '<DBAccount at 0x134360d0>' is not > persisted > > On 11 Sie, 01:34, grassoalvaro <[email protected]> wrote: >> Hi, >> >> example from Pylons application, but i think that framework doesn't >> matter here: >> >> class DBAccountExtension(orm.interfaces.MapperExtension): >> def after_insert(self, mapper, connection, instance): >> response = hrd.user_create(instance.to_hrd()) >> if response['status'] == hrd.STATUS_OK: >> instance.csa = response['resdata']['user']['id'] >> db.save_or_update(instance) >> db.commit() >> return orm.interfaces.EXT_CONTINUE >> >> After saving model i'm making request to some API (to save data there >> also). API return status information (response['resdata']['user'] >> ['id']) which i want to update in database so i'm trying to do >> db.save_or_update(instance) and then db.commit() but after this 2 >> lines application prints exception: >> >> InvalidRequestError: The transaction is closed >> >> Any solutions? >> >> (sorry for my english). > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
