From f9071ac6e9293084ff3c31f2ac0a754a69e58ceb Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 4 Mar 2020 13:29:47 -0600 Subject: [PATCH] Remove DB-related things from the Rattail -> CORE datasync consumer since that should only use API, going forward --- rattail_corepos/datasync/corepos.py | 31 ++++++++++------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/rattail_corepos/datasync/corepos.py b/rattail_corepos/datasync/corepos.py index 7ea713b..05056b2 100644 --- a/rattail_corepos/datasync/corepos.py +++ b/rattail_corepos/datasync/corepos.py @@ -138,17 +138,6 @@ class FromRattailToCore(NewDataSyncImportConsumer): """ handler_spec = 'rattail_corepos.corepos.importing.rattail:FromRattailToCore' - def begin_transaction(self): - self.corepos_session = CoreSession() - - def rollback_transaction(self): - self.corepos_session.rollback() - self.corepos_session.close() - - def commit_transaction(self): - self.corepos_session.commit() - self.corepos_session.close() - def process_changes(self, session, changes): """ Process all the given changes, coming from Rattail. @@ -157,27 +146,27 @@ class FromRattailToCore(NewDataSyncImportConsumer): if self.runas_username: session.set_continuum_user(self.runas_username) - # update all importers with current Rattail/CORE sessions + # update all importers with current session for importer in self.importers.values(): importer.host_session = session - importer.session = self.corepos_session # also establish the API client for each! importer.establish_api() - # next pass syncs all Vendor changes + # sync all Vendor changes types = [ 'Vendor', 'VendorPhoneNumber', 'VendorEmailAddress', ] for change in [c for c in changes if c.payload_type in types]: - vendor = self.get_host_vendor(session, change) - if vendor: - # TODO: what about "deletions" - not sure what happens yet - self.process_change(session, self.importers['Vendor'], - host_object=vendor) - # self.process_change(session, self.importers['VendorContact'], - # host_object=vendor) + if change.payload_type == 'Vendor' and change.deletion: + # just do default logic for this one + self.invoke_importer(session, change) + else: # we consider this a "vendor add/update" + vendor = self.get_host_vendor(session, change) + if vendor: + self.process_change(session, self.importers['Vendor'], + host_object=vendor) def get_host_vendor(self, session, change):