twoscoops / two-scoops-of-django-1.6

Tracking thoughts and feature requests for Two Scoops of Django 1.6
51 stars 7 forks source link

Example 6.7 does not need decorator #74

Open adriaant opened 10 years ago

adriaant commented 10 years ago

Since you are using "with transaction.atomic()", the code wrapped by transaction.atomic() will only commit changes to database on success, whether you have the non_atomic_requests decorator or not. I believe that's what the docs state @ https://docs.djangoproject.com/en/1.6/topics/db/transactions/#django.db.transaction.atomic

pydanny commented 9 years ago

I believe you are overthinking this example. However, just to be certain I'll ask @aaugustin to weigh in.

aaugustin commented 9 years ago

I saw this comment today. I must have missed the notification.

In that example, @transaction.non_atomic_requests ensures that with transaction.atomic() maps to a database transaction and not just a savepoint. So the example is correct in this regard.

However, the last line # If the transaction fails will never be reached. Only an exception can cause the transaction to fail and there's no code to handle such an exception.