If I try to create a transaction object and it fails in its __init__ method (for example it cannot get a connection because the db is down) the _obsolete attribute will be missing and when __del__ is called to destroy the unrealized object it will oscillate forever between the __getattr__ and assertActive functions with the following error:
Exception exceptions.RuntimeError: 'maximum recursion depth exceeded' in <bound method Transaction.__del__ of <sqlobject.dbconnection.Transaction object at 0xb7a761ec>> ignored The attached patch fixes the problem. The patch also has the effect of avoiding to call for rollback() in the __del__ method, if the creation of the transaction object fails in __init__. -- Dan
--- sqlobject.orig/dbconnection.py 2005-10-02 01:59:35.000000000 +0300 +++ sqlobject/dbconnection.py 2006-05-31 13:36:49.000000000 +0300 @@ -718,6 +718,7 @@ class Transaction(object): def __init__(self, dbConnection): + self._obsolete = True self._dbConnection = dbConnection self._connection = dbConnection.getConnection() self._dbConnection._setAutoCommit(self._connection, 0)