#2227: transaction.commit()/rollback() should be aware of nested calls to
transaction.managed(True)
-------------------------------------+-------------------------------------
               Reporter:  mderk@…    |        Owner:  nobody
                   Type:  New        |       Status:  assigned
  feature                            |    Component:  Database layer
              Milestone:             |  (models, ORM)
                Version:  SVN        |     Severity:  Normal
             Resolution:             |     Keywords:  transaction, nest,
           Triage Stage:  Accepted   |  scope, nested, rollback, commit
    Needs documentation:  0          |    Has patch:  1
Patch needs improvement:  1          |  Needs tests:  0
-------------------------------------+-------------------------------------
Changes (by etianen):

 * cc: etianen (added)


Comment:

 I agree that nested calls to transaction management commands should
 transparent start using savepoints. It seems like the obvious abstraction
 layer.

 However, for backends which do not support savepoints, what would the
 fallback be? The only thing I can think of is to check for nesting and
 only allow transactions to commit in the outer nested block. This means
 that different backends will behave very differently, massively breaking
 the abstraction.

 For backwards compatibility, the current transaction handling methods will
 probably have to stay, as they provide a 'broken', yet consistent way of
 handling transactions between backends. There are workarounds for core
 framework features, such as #15694. However, a new set of decorators with
 a slightly different API could be provided in parallel, with a signature
 something like this:

 {{{
 @transaction.commit_block(savepoint=False)
 def do_something(request):
     # Do something...
 }}}

 This decorator (with a better name), would work like commit_on_success,
 but only actually perform the commit when the outer block exits. The
 optional savepoint=True parameter would provide more fine-grained rollback
 support using savepoints, but generate a warning on backends which do not
 support savepoints. The core framework could use this on things like the
 admin views, but would avoid using the savepoint support (this is for
 individual projects to decide).

-- 
Ticket URL: <http://code.djangoproject.com/ticket/2227#comment:27>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to