Add better error handling when batch refresh fails, etc.
Also don't force refresh when view is requested; instead just do a refresh after batch is first created.
This commit is contained in:
parent
3e940e3c14
commit
50430e89db
|
@ -531,7 +531,18 @@ class BatchCrud(BaseCrud):
|
|||
# transaction binding etc.
|
||||
session = RatSession()
|
||||
batch = session.query(self.batch_class).get(batch_uuid)
|
||||
try:
|
||||
self.refresh_data(session, batch, progress=progress)
|
||||
except Exception as error:
|
||||
session.rollback()
|
||||
log.exception("refreshing data for batch failed: {0}".format(batch))
|
||||
session.close()
|
||||
progress.session.load()
|
||||
progress.session['error'] = True
|
||||
progress.session['error_msg'] = "Data refresh failed: {0}".format(error)
|
||||
progress.session.save()
|
||||
return
|
||||
|
||||
session.commit()
|
||||
session.refresh(batch)
|
||||
session.close()
|
||||
|
@ -572,13 +583,13 @@ class FileBatchCrud(BatchCrud):
|
|||
"""
|
||||
refreshable = True
|
||||
|
||||
def pre_crud(self, batch):
|
||||
def post_create_url(self, form):
|
||||
"""
|
||||
Force refresh if batch has yet to be cognized.
|
||||
Redirect to refresh batch after creating a batch.
|
||||
"""
|
||||
if not self.creating and not batch.cognized:
|
||||
return HTTPFound(location=self.request.route_url(
|
||||
'{0}.refresh'.format(self.route_prefix), uuid=batch.uuid))
|
||||
batch = form.fieldset.model
|
||||
Session.flush()
|
||||
return self.refresh_url(batch.uuid)
|
||||
|
||||
@property
|
||||
def upload_dir(self):
|
||||
|
|
Loading…
Reference in a new issue