wrap batch execution with transaction.manager

This commit is contained in:
Lance Edgar 2012-04-10 14:31:42 -05:00
parent 81f6b57a63
commit b28631d421

View file

@ -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