Fixed transaction management

Create issue
Issue #1285 resolved
Hynek Cernoch created an issue

== Fixed transaction management

I found small issues related to the transaction management in import products.

Every product import (http://localsite/inventory/import/) adds one level to the transaction management status stack. It never returns back and stays in the status //dirty//.

  • Test

  • logging of //state// for local thread and default connection in django/db/, line 139, function //is_managed//.

  • Import some products several times.

{{{ [] ... [True] "POST /inventory/import/ HTTP/1.1" 200 2584 [True] ... [True, True] "POST /inventory/import/ HTTP/1.1" 200 2584 [True, True] ... [True, True, True] "POST /inventory/import/ HTTP/1.1" 200 2584 [True, True, True] ... [True, True, True, True] "POST /inventory/import/ HTTP/1.1" 200 2584 }}}

  • Fix

Fix with minimal modifications of the code is this shema: {{{ try: enter_transaction_management() do something ... commit() except: rollback() leave_transaction_management() else: leave_transaction_management() }}}

This ensures symmetry of enter/leave both on fail and on success.

Complete patch is in the post below.

Comments (2)

  1. Log in to comment