This is not exactly what i was looking for. I want to connect only one model with some kind of operations, not all session...
On 11 Sie, 19:36, "Michael Bayer" <mike...@zzzcomputing.com> wrote: > grassoalvaro wrote: > > > Hmm, but after_insert() is the best place where i can put this king > > logic (updating/inserting data in may places). So i can't use session > > operations inside of after_insert() at all? > > nope. use before_flush() or after_flush() on SessionExtension for that. > > > > > On 11 Sie, 18:35, "Michael Bayer" <mike...@zzzcomputing.com> wrote: > >> 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 <grassoalv...@yahoo.com> 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 sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---