title: Django 1.6 and nesting "with transaction.atomic()"
body: <p>I've got used through the years to the older transaction.commit_on_success and transaction.commit_manually with Django &lt; 1.6. But now with Django 1.6 the old API is replaced mainly with transaction.atomic.</p>
  
  <p><a href="https://docs.djangoproject.com/en/dev/topics/db/transactions/#controlling-transactions-explicitly">After reading the docs on the new API</a>, I'm still not sure how the following code will be committed to the database:</p>
  
  <pre><code>def a_first_function():
      with transaction.atomic():
          a_second_function_successful()
          a_third_function_fails()
  
  def a_second_function_successful():
      with transaction.atomic():
          do_something()
  
  def a_third_function_fails():
      do_something_wrong()
  </code></pre>
  
  <p>In this example, let's assume that a_second_function_successful called from a_first_function succeeds and creates/saves objects from models. Immediately after this second_function succeeds, the third function is called and fails.</p>
  
  <p>Given that transaction.atomic using the context manager is both used in the first and second function, what will happen to the data created/modified in a_second_function_successful. Will it be committed to the database? Will it be rolled back automatically from the first function? My experience is that it the second function will be committed regardless, however, I expected it not to be committed.</p>
  
  <p>Would it make any difference now if the third function was defined as the following:</p>
  
  <pre><code>@transaction.atomic
  def a_third_function_fails():
      do_something_wrong()
  </code></pre>
  
  <p>or as:</p>
  
  <pre><code>def a_third_function_fails():
      with transaction.atomic():
          do_something_wrong()
  </code></pre>
  
  <p>Thanks,</p>