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