The code bellow throwing error "ObjectDeletedError: Instance 'xxx' has been 
deleted." when a exception throwing from "method1".
Eroor in line method1(db_obj1.id),  db_obj1.id failing.

How fix this issue.


def main_method():
    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 = create_new_obj(id)
        DBSession.add(db_obj1)
        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/-/ya-rKw3XinwJ.
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.

Reply via email to