Because the scoping of the transactions makes it hard I imagine. A view 
could start more than one transaction for instance, and one of those might 
succeed and the other might get rolled back. Thinking more about this, a 
system like this might get hard to implement. Even if thread locals are 
used, one might have to clear the list in cases of rollbacks or at least 
partially clear it for savepoint rollbacks. And all that doesn't even 
consider autocommit yet :) 

On Sunday, October 10, 2021 at 5:39:18 PM UTC+2 Shai Berger wrote:

> Just to clarify the use-case: 
>
> Why is a before-commit signal preferable to a vanilla Python 
> context-manager around the code? Or, if it is in the context of 
> requests, a middleware? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/549f5570-8cf3-4a1a-b381-e72a5d15d66en%40googlegroups.com.

Reply via email to