From 24d4afa22b2bf69be4df7ff367282dfb10a85fd4 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 8 May 2023 14:55:07 -0500 Subject: [PATCH] Move CORE DB import handler to more general location --- .../corepos/office/importing/db/corepos.py | 19 ++++++------------- .../corepos/office/importing/db/model.py | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/rattail_corepos/corepos/office/importing/db/corepos.py b/rattail_corepos/corepos/office/importing/db/corepos.py index d786f43..08aa231 100644 --- a/rattail_corepos/corepos/office/importing/db/corepos.py +++ b/rattail_corepos/corepos/office/importing/db/corepos.py @@ -28,9 +28,9 @@ from collections import OrderedDict from corepos.db.office_op import Session as CoreSession -from rattail.importing.handlers import FromSQLAlchemyHandler, ToSQLAlchemyHandler +from rattail.importing.handlers import FromSQLAlchemyHandler from rattail.importing.sqlalchemy import FromSQLAlchemySameToSame -from rattail_corepos.corepos.importing import db as corepos_importing +from rattail_corepos.corepos.office.importing import db as corepos_importing class FromCoreHandler(FromSQLAlchemyHandler): @@ -44,15 +44,8 @@ class FromCoreHandler(FromSQLAlchemyHandler): return CoreSession() -class ToCoreHandler(ToSQLAlchemyHandler): - """ - Base class for import handlers which target a CORE database on the local side. - """ - local_title = "CORE" - local_key = 'corepos_db_office_op' - - def make_session(self): - return CoreSession() +# TODO: deprecate / remove this +ToCoreHandler = corepos_importing.model.ToCoreHandler class FromCoreToCoreBase(object): @@ -77,7 +70,7 @@ class FromCoreToCoreBase(object): return importers -class FromCoreToCoreImport(FromCoreToCoreBase, FromCoreHandler, ToCoreHandler): +class FromCoreToCoreImport(FromCoreToCoreBase, FromCoreHandler, corepos_importing.model.ToCoreHandler): """ Handler for CORE (other) -> CORE (local) data import. @@ -97,7 +90,7 @@ class FromCoreToCoreImport(FromCoreToCoreBase, FromCoreHandler, ToCoreHandler): return CoreSession(bind=self.config.corepos_engines[self.dbkey]) -class FromCoreToCoreExport(FromCoreToCoreBase, FromCoreHandler, ToCoreHandler): +class FromCoreToCoreExport(FromCoreToCoreBase, FromCoreHandler, corepos_importing.model.ToCoreHandler): """ Handler for CORE (local) -> CORE (other) data export. diff --git a/rattail_corepos/corepos/office/importing/db/model.py b/rattail_corepos/corepos/office/importing/db/model.py index 2cb8c95..805b271 100644 --- a/rattail_corepos/corepos/office/importing/db/model.py +++ b/rattail_corepos/corepos/office/importing/db/model.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2020 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -31,12 +31,22 @@ CORE-POS model importers (direct DB) which may exist. """ -from sqlalchemy.orm.exc import NoResultFound +from corepos.db.office_op import model as corepos, Session as CoreSession +from corepos.db.office_trans import model as coretrans from rattail import importing +from rattail.importing.handlers import ToSQLAlchemyHandler -from corepos.db.office_op import model as corepos -from corepos.db.office_trans import model as coretrans + +class ToCoreHandler(ToSQLAlchemyHandler): + """ + Base class for import handlers which target a CORE database on the local side. + """ + local_title = "CORE" + local_key = 'corepos_db_office_op' + + def make_session(self): + return CoreSession() class ToCore(importing.ToSQLAlchemy):