diff --git a/rattail_corepos/batch/vendorcatalog.py b/rattail_corepos/batch/vendorcatalog.py index ff6cb00..2f8de57 100644 --- a/rattail_corepos/batch/vendorcatalog.py +++ b/rattail_corepos/batch/vendorcatalog.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2021 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -27,7 +27,6 @@ Handler for Vendor Catalog batches import decimal from rattail.batch import vendorcatalog as base -from rattail_corepos.corepos.api import make_corepos_api class VendorCatalogHandler(base.VendorCatalogHandler): @@ -73,7 +72,7 @@ class VendorCatalogHandler(base.VendorCatalogHandler): if not vendor_id: raise ValueError("Batch vendor does not have valid CORE-POS ID") - self.api = make_corepos_api(self.config) + self.api = self.get_corepos_handler.make_webapi() self.update_corepos(batch, rows, vendor_id, progress=progress, # update_product_costs=kwargs.get('update_product_costs', False), ) diff --git a/rattail_corepos/corepos/office/commands.py b/rattail_corepos/corepos/office/commands.py index 5b45913..08f7b15 100644 --- a/rattail_corepos/corepos/office/commands.py +++ b/rattail_corepos/corepos/office/commands.py @@ -34,7 +34,6 @@ from rattail import commands from rattail_corepos import __version__ from rattail.util import load_object from rattail_corepos.corepos.office.util import get_fannie_config_value -from rattail_corepos.corepos.api import make_corepos_api from rattail_corepos.corepos.util import get_core_members from rattail_corepos.config import core_office_url @@ -91,10 +90,7 @@ class Anonymize(commands.Subcommand): "\tpip install names\n") sys.exit(2) - from rattail_corepos.corepos.api import make_corepos_api - from rattail_corepos.corepos.util import get_core_members - - api = make_corepos_api(self.config) + api = self.app.get_corepos_handler().make_webapi() members = get_core_members(self.config, api, progress=self.progress) def anonymize(member, i): @@ -236,7 +232,7 @@ class PatchCustomerGaps(commands.Subcommand): def run(self, args): from corepos.db.office_op import model as corepos - corepos_api = make_corepos_api(self.config) + corepos_api = self.app.get_corepos_handler().make_webapi() members = get_core_members(self.config, corepos_api, progress=self.progress) tally = self.app.make_object(updated=0) diff --git a/rattail_corepos/corepos/office/importing/model.py b/rattail_corepos/corepos/office/importing/model.py index 4d03801..2a145ee 100644 --- a/rattail_corepos/corepos/office/importing/model.py +++ b/rattail_corepos/corepos/office/importing/model.py @@ -27,7 +27,6 @@ CORE-POS model importers (webservices API) from rattail import importing from rattail.util import data_diffs from rattail_corepos.corepos.util import get_core_members -from rattail_corepos.corepos.api import make_corepos_api class ToCOREAPIHandler(importing.ImportHandler): @@ -83,7 +82,7 @@ class ToCoreAPI(importing.Importer): self.establish_api() def establish_api(self): - self.api = make_corepos_api(self.config) + self.api = self.app.get_corepos_handler().make_webapi() def ensure_fields(self, data): """ diff --git a/rattail_corepos/datasync/rattail.py b/rattail_corepos/datasync/rattail.py index 48152c1..0f1c56f 100644 --- a/rattail_corepos/datasync/rattail.py +++ b/rattail_corepos/datasync/rattail.py @@ -29,7 +29,6 @@ from sqlalchemy import orm from corepos.db.office_op import Session as CoreSession, model as corepos from rattail.datasync import DataSyncImportConsumer -from rattail_corepos.corepos.api import make_corepos_api class FromCOREAPIToRattail(DataSyncImportConsumer): @@ -42,11 +41,11 @@ class FromCOREAPIToRattail(DataSyncImportConsumer): } def setup(self): - super(FromCOREAPIToRattail, self).setup() + super().setup() self.establish_api() def establish_api(self): - self.api = make_corepos_api(self.config) + self.api = self.app.get_corepos_handler().make_webapi() def pre_process_changes(self, session, changes): diff --git a/rattail_corepos/importing/corepos/api.py b/rattail_corepos/importing/corepos/api.py index af7a8a6..1ebb3d2 100644 --- a/rattail_corepos/importing/corepos/api.py +++ b/rattail_corepos/importing/corepos/api.py @@ -38,7 +38,6 @@ from rattail.core import get_uuid from rattail.db.util import normalize_full_name from rattail_corepos import importing as corepos_importing from rattail_corepos.corepos.util import get_core_members -from rattail_corepos.corepos.api import make_corepos_api log = logging.getLogger(__name__) @@ -100,7 +99,7 @@ class FromCOREPOSAPI(importing.Importer): self.establish_api() def establish_api(self): - self.api = make_corepos_api(self.config) + self.api = self.get_corepos_handler().make_webapi() def should_ignore_new_members(self): if hasattr(self, 'ignore_new_members'):