Remove DB-related things from the Rattail -> CORE datasync consumer

since that should only use API, going forward
This commit is contained in:
Lance Edgar 2020-03-04 13:29:47 -06:00
parent 4180382250
commit f9071ac6e9

View file

@ -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):