As MIDDLEWARE supports decorator-like objects you could simply add 
`django.db.transaction.atomic' to it and you'd get each request wrapped in 
a transaction.

Note that this will only start a transaction on the `default` database, 
just like the old TransactionMiddleware use to do.

Simon

Le mercredi 18 mai 2016 06:14:04 UTC-4, Florian Apolloner a écrit :
>
> Starting with Django 1.10 you can write a TransactionMiddleware again, and 
> we will probably ship one again.
>
> On Tuesday, May 10, 2016 at 2:07:30 AM UTC+2, Kevin Tran wrote:
>>
>> Thomas, did you ever find a solution to your problem?  I'm having similar 
>> thoughts and am looking for an answer.
>>
>> On Friday, February 6, 2015 at 4:18:53 AM UTC-8, guettli wrote:
>>>
>>>
>>>
>>> Am 04.02.2015 um 14:04 schrieb Anssi Kääriäinen: 
>>> > I'd really like to be able to define middlewares that actually work in 
>>> > a well defined and easy to use way. Currently, there is no 
>>> > guarantee(!) that either process_exception or process_response gets 
>>> > called after process_request has been called for given middleware, and 
>>> > this makes it impossible to implement a transaction middleware purely 
>>> > as a middleware. 
>>>
>>> It's the same with TestCase.setUp() and TestCase.tearDown() does not 
>>> work 
>>> well together with decorators. 
>>>
>>> You are right. Instead of 
>>>
>>>   settings.MIDDLEWARES_INSIDE_TRANSACTION 
>>>
>>>   settings.CONTEXT_MANAGERS 
>>>
>>> would be better. 
>>>
>>> The atomic() could be one entry in the list of context managers. 
>>>
>>> > An idea... Would investigating and implementing better middlewares (or 
>>> > urlpattern wrappers) make for a good GSoC project? Maybe the "wrap 
>>> > URLs" approach could be part of the URL resolve refactoring GSoC 
>>> > project? 
>>>
>>> I don't know if GSoC is a good solution. It is appealing, since 
>>> it looks that someone else does the work (not me and my team mates). 
>>> But I am a little bit afraid that will this result in a more complicated 
>>> implementation. My perfect solution are only very few lines of code. 
>>> I guess this could be possible. I guess the diff for the docs 
>>> could be longer then the diff for the code. 
>>>
>>> Regards, 
>>>    Thomas 
>>>
>>> -- 
>>> Thomas Güttler 
>>> http://thomas-guettler.de/ 
>>>
>>

-- 
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 post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3602ab24-40a9-4ab6-b5f4-ffd5b52872af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to