Use common logic for fetching batch handler
This commit is contained in:
parent
ae1e9dba0f
commit
f0b6b62791
|
@ -45,7 +45,7 @@ from sqlalchemy import orm
|
||||||
from rattail.db import model, Session as RattailSession
|
from rattail.db import model, Session as RattailSession
|
||||||
from rattail.db.util import short_session
|
from rattail.db.util import short_session
|
||||||
from rattail.threads import Thread
|
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
|
from rattail.progress import SocketProgress
|
||||||
|
|
||||||
import colander
|
import colander
|
||||||
|
@ -142,12 +142,13 @@ class BatchMasterView(MasterView):
|
||||||
``batch_key`` attribute of the main batch model class.
|
``batch_key`` attribute of the main batch model class.
|
||||||
"""
|
"""
|
||||||
# first try to figure out if config defines a factory class
|
# first try to figure out if config defines a factory class
|
||||||
|
app = rattail_config.get_app()
|
||||||
model_class = cls.get_model_class()
|
model_class = cls.get_model_class()
|
||||||
batch_key = model_class.batch_key
|
batch_key = model_class.batch_key
|
||||||
spec = rattail_config.get('rattail.batch', '{}.handler'.format(batch_key),
|
handler = app.get_batch_handler(batch_key,
|
||||||
default=cls.default_handler_spec)
|
default=cls.default_handler_spec)
|
||||||
if spec: # yep, so use that
|
if handler:
|
||||||
return load_object(spec)
|
return handler.__class__
|
||||||
|
|
||||||
# fall back to whatever class was defined statically
|
# fall back to whatever class was defined statically
|
||||||
return cls.batch_handler_class
|
return cls.batch_handler_class
|
||||||
|
|
Loading…
Reference in a new issue