Move CORE DB import handler to more general location

This commit is contained in:
Lance Edgar 2023-05-08 14:55:07 -05:00
parent ef823260ab
commit 24d4afa22b
2 changed files with 20 additions and 17 deletions

View file

@ -28,9 +28,9 @@ from collections import OrderedDict
from corepos.db.office_op import Session as CoreSession 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.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): class FromCoreHandler(FromSQLAlchemyHandler):
@ -44,15 +44,8 @@ class FromCoreHandler(FromSQLAlchemyHandler):
return CoreSession() return CoreSession()
class ToCoreHandler(ToSQLAlchemyHandler): # TODO: deprecate / remove this
""" ToCoreHandler = corepos_importing.model.ToCoreHandler
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 FromCoreToCoreBase(object): class FromCoreToCoreBase(object):
@ -77,7 +70,7 @@ class FromCoreToCoreBase(object):
return importers return importers
class FromCoreToCoreImport(FromCoreToCoreBase, FromCoreHandler, ToCoreHandler): class FromCoreToCoreImport(FromCoreToCoreBase, FromCoreHandler, corepos_importing.model.ToCoreHandler):
""" """
Handler for CORE (other) -> CORE (local) data import. 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]) 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. Handler for CORE (local) -> CORE (other) data export.

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar # Copyright © 2010-2023 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -31,12 +31,22 @@ CORE-POS model importers (direct DB)
which may exist. 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 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): class ToCore(importing.ToSQLAlchemy):