Inside code using Connection objects to issue queries, it would be nice to assert that the Connection is inside a transaction. This allows production code using the library to nicely separate the code handling the fetching of Connections from the code issuing queries while still allowing the latter to make assertions about the context it's in.
Looking at the code, there is a member variable _top_xact which is None if not inside a transaction block, and which is set to the Transaction object otherwise. Thus, it appears to me that simply checking the value of this variable is sufficient for this method. Correct me if I'm missing anything.
Inside code using Connection objects to issue queries, it would be nice to assert that the Connection is inside a transaction. This allows production code using the library to nicely separate the code handling the fetching of Connections from the code issuing queries while still allowing the latter to make assertions about the context it's in.
Looking at the code, there is a member variable
_top_xactwhich is None if not inside a transaction block, and which is set to the Transaction object otherwise. Thus, it appears to me that simply checking the value of this variable is sufficient for this method. Correct me if I'm missing anything.