wrap batch execution with transaction.manager
This commit is contained in:
parent
81f6b57a63
commit
b28631d421
|
@ -29,6 +29,7 @@
|
|||
import formalchemy
|
||||
from sqlalchemy import and_, or_
|
||||
|
||||
import transaction
|
||||
from pyramid.httpexceptions import HTTPFound
|
||||
from pyramid.renderers import render
|
||||
from pyramid.response import Response
|
||||
|
@ -801,9 +802,11 @@ def execute(context, request):
|
|||
# print 'got a batch'
|
||||
|
||||
uuid = request.matchdict['uuid']
|
||||
batch = Session.query(rattail.Batch).get(uuid) if uuid else None
|
||||
if not batch:
|
||||
return home
|
||||
|
||||
with transaction.manager:
|
||||
batch = Session.query(rattail.Batch).get(uuid) if uuid else None
|
||||
if not batch:
|
||||
return home
|
||||
# print 'got a batch'
|
||||
|
||||
# jct = batch.target_junction
|
||||
|
@ -822,7 +825,7 @@ def execute(context, request):
|
|||
# jct.export_main_item(batch, self.Session)
|
||||
# print 'exported main item'
|
||||
|
||||
batch.execute()
|
||||
batch.execute()
|
||||
|
||||
# table = batch.table
|
||||
# rowclass = batch.rowclass
|
||||
|
@ -836,8 +839,8 @@ def execute(context, request):
|
|||
# # table.drop(bind=self.Session().bind, checkfirst=False)
|
||||
# # print 'dropped table'
|
||||
|
||||
request.session.flash("The batch was executed: %s, %s" % (
|
||||
batch.target, rattail.BATCH_ACTION_TYPE[batch.action_type]))
|
||||
request.session.flash("The batch was executed: %s, %s" % (
|
||||
batch.target, rattail.BATCH_ACTION_TYPE[batch.action_type]))
|
||||
return home
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue