From f0b6b627914ed8077656d8341bf1e5a0776bfc08 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 25 Mar 2022 13:49:39 -0500 Subject: [PATCH] Use common logic for fetching batch handler --- tailbone/views/batch/core.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py index 61c893e9..7d6216d3 100644 --- a/tailbone/views/batch/core.py +++ b/tailbone/views/batch/core.py @@ -45,7 +45,7 @@ from sqlalchemy import orm from rattail.db import model, Session as RattailSession from rattail.db.util import short_session from rattail.threads import Thread -from rattail.util import load_object, prettify, simple_error +from rattail.util import prettify, simple_error from rattail.progress import SocketProgress import colander @@ -142,12 +142,13 @@ class BatchMasterView(MasterView): ``batch_key`` attribute of the main batch model class. """ # first try to figure out if config defines a factory class + app = rattail_config.get_app() model_class = cls.get_model_class() batch_key = model_class.batch_key - spec = rattail_config.get('rattail.batch', '{}.handler'.format(batch_key), - default=cls.default_handler_spec) - if spec: # yep, so use that - return load_object(spec) + handler = app.get_batch_handler(batch_key, + default=cls.default_handler_spec) + if handler: + return handler.__class__ # fall back to whatever class was defined statically return cls.batch_handler_class