H, Michael Bayer Thanks You are correct, the rollback in method1 rollbacking transaction in main_method. I want to isolate transaction in main_method from rollback in method1.
I attached more code. from sqlalchemy.orm import scoped_session, sessionmaker maker = sessionmaker(autoflush=True, autocommit=False,expire_on_commit=False, extension=ZopeTransactionExtension()) zopelessmaker = sessionmaker(autoflush=True, \ autocommit=False, \ expire_on_commit=False) DBSession = scoped_session(maker) def main_method(): db_obj1 = DBModelclass1("Hello") DBSession.add(db_obj1) DBSession.fush() for x in lst: try: method1(db_obj1.id) excpt Exception, ex: pass def method1(id): try: s1 = DBSession() s1.begin_nested() db_obj2 = DBModelclass2("Test") db_obj2.refname = "name_%s" %(id) DBSession.add(db_obj2) DBSession.fush() if some-codition: raise Exception("Failedd") s1.commit() except Exception, ex: s1.rollback() raise ex -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/uIJwy6KOAdsJ. 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.