#15317: TransactionManagementError  exception on a clean transaction
--------------------------------------------------------+-------------------
               Reporter:  jbl1                          |         Owner:  nobody
                 Status:  closed                        |     Milestone:        
              Component:  Database layer (models, ORM)  |       Version:  SVN   
             Resolution:  invalid                       |      Keywords:        
           Triage Stage:  Unreviewed                    |     Has patch:  0     
    Needs documentation:  0                             |   Needs tests:  0     
Patch needs improvement:  0                             |  
--------------------------------------------------------+-------------------

Comment (by jbl1):

 Replying to [comment:1 russellm]:
 > Sounds like you've been tripped up by r15493. However, since you haven't
 provided any details that would allow us to reproduce your problem, I
 can't confirm or deny this.
 >
 > If you are reporting a problem, you need to provide enough detail for
 someone else to reproduce the problem *exactly*. It's no good giving vague
 descriptions -- we need specific code samples, or at the very least,
 precise instructions that will allow someone else to reproduce the problem
 you are seeing.
 >
 > Closing invalid. Please reopen if you can provide the necessary detail.

 Indeed, I was quite vague. My test view was:


 {{{
 @transaction.commit_manually
 def test(request):
     return render_to_response("bdo/test.html", RequestContext(request))
 }}}

 and it failed in my environment with the !TransactionManagementError
 exception. When trying to further minimize the example for the purpose of
 reopening this ticket, I removed the call to !RequestContext like so:


 {{{
 @transaction.commit_manually
 def test(request):
     return render_to_response("bdo/test.html")
 }}}

 and then the view passed.
 It turned out that I have a custom context processor which accesses the
 database to determine the menu functions available to the logged on user
 thus dirtying the transaction. I now do a conditional transaction.commit()
 in the context processor:


 {{{
 def create_menu(request):
    # ...
    # a database read
    if transaction.is_managed() :
       transaction.commit()
    # ...
 }}}
 which seems to solve the problem.

 So it turns out that the ticket as stated is indeed invalid. Nonetheless,
 to prevent others tripping over in similar circumstances it might be
 helpful to amend at least the 1.3 release notes
 (http://docs.djangoproject.com/en/dev/releases/1.3/#transaction-
 management) and perhaps also the Managing database transactions section of
 the documentation
 (http://docs.djangoproject.com/en/dev/topics/db/transactions/). Sorry for
 not providing a sample wording...

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15317#comment:2>
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