Log warning instead of assertion error, if runas_user doesn't exist
within context of X -> Rattail importer, in local/target session
This commit is contained in:
parent
e18250faff
commit
879fc2f1e5
|
@ -26,6 +26,8 @@ Rattail -> Rattail data import
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
||||||
from rattail.db import Session
|
from rattail.db import Session
|
||||||
|
@ -35,6 +37,9 @@ from rattail.importing.sqlalchemy import FromSQLAlchemySameToSame
|
||||||
from rattail.util import OrderedDict
|
from rattail.util import OrderedDict
|
||||||
|
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FromRattailHandler(FromSQLAlchemyHandler):
|
class FromRattailHandler(FromSQLAlchemyHandler):
|
||||||
"""
|
"""
|
||||||
Base class for import handlers which target a Rattail database on the local side.
|
Base class for import handlers which target a Rattail database on the local side.
|
||||||
|
@ -69,9 +74,13 @@ class ToRattailHandler(ToSQLAlchemyHandler):
|
||||||
# load "runas user" into current session
|
# load "runas user" into current session
|
||||||
if hasattr(self, 'runas_user') and self.runas_user:
|
if hasattr(self, 'runas_user') and self.runas_user:
|
||||||
dbmodel = self.config.get_model()
|
dbmodel = self.config.get_model()
|
||||||
self.runas_user = self.session.query(dbmodel.User)\
|
runas_user = self.session.query(dbmodel.User)\
|
||||||
.get(self.runas_user.uuid)
|
.get(self.runas_user.uuid)
|
||||||
assert self.runas_user
|
if not runas_user:
|
||||||
|
log.warning("runas_user does not exist in target session: %s",
|
||||||
|
self.runas_user.username)
|
||||||
|
# this may be None if user does not exist in target session
|
||||||
|
self.runas_user = runas_user
|
||||||
|
|
||||||
# declare "runas user" is data versioning author
|
# declare "runas user" is data versioning author
|
||||||
if hasattr(self, 'runas_username') and self.runas_username:
|
if hasattr(self, 'runas_username') and self.runas_username:
|
||||||
|
|
Loading…
Reference in a new issue