Hello, fellow devs. I have been googling intensively in order to see whether somebody already raised such issue, but so far I have been unsuccesful. Therefore, trembling on my legs, I decided to write to the devlist as suggested in the docs.
I am trying to extend the atomic decorator / context statement in order to do 'prepare transaction \'foo\'' rather than usual 'commit' on succesful transaction. It is, however, not the usual scenario where django would talk to multiple databases. What I have in mind is a bunch of microservices, one of them which would be django application. Therefore django app would be talking to the external transaction manager which would then take care of executing the appropriate transactions inside of each microservice. I suppose that after a bunch of hacking I could implement this with some monkey patching of the original atomic() code but it clearly is not the way to go. I then started to think how this could be done database-agnostic way. I know that PostgreSQL supports this with 'prepare transaction' statement, but I suppose that other databases have different syntax for this kind of behaviour and some don't support this feature at all. Therefore I thought that in e.g. SQLite3 (or other database which doesn't support this natively), this behavior could be 'emulated'. Therefore I thought of the following pseudocode: ``` with transaction.atomic(commit_hook=lambda connection: connection.prepare_transaction('foo')) OR with transaction.atomic(prepare_transaction='foo') ``` When you would do CRUD operations they would be instead serialized inside a special table, and then, after issuing another command, say .. from django.db import transaction transaction.commit_prepared('foo') they would be applied using regular 'atomic' call. (or.. I don't know, Django could raise an IntegrityError if the database doesn't support distributed transactions and the code would try to execute them) Do you think that this is realistic or is it a wrong approach to the subject? kind regards, -- 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/8d358e52-591d-4b9b-8c11-882e6a2ac80d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.