Hi, My code is like that:
try: for some_val in some_values: rec = SomeModel() rec.some_val = some_val session.save(rec) session.commit() except: session.rollback() For each record that I'm creating, I need to send an email right after. And each email includes some data about these records, especially the "rec.id". Everything looks fine but the problem is getting the "rec.id". I've tried: try: for some_val in some_values: rec = SomeModel() rec.some_val = some_val session.save(rec) email(rec=rec) # rec doesn't have "id" yet so it doesn't work session.commit() except: session.rollback() for some_val in some_values: rec = SomeModel() rec.some_val = some_val session.save() session.commit() email(rec=rec) # It works, but now I don't have a chance to rollback() anymore It seems like I need something whcih will trigger right after a new record is posted. I couldn't find any good solution. Now I need to learn what is the best way to do that. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---