diff --git a/src/python/dm/common/utility/objectUtility.py b/src/python/dm/common/utility/objectUtility.py index 70c815332d5d792ff69c8ac0d9e54601e9f3523a..ddba57b0d09f37a1eb5d874c0553d6f4decc0d58 100755 --- a/src/python/dm/common/utility/objectUtility.py +++ b/src/python/dm/common/utility/objectUtility.py @@ -5,12 +5,20 @@ from dm.common.utility.loggingManager import LoggingManager class ObjectUtility: @classmethod - def createObjectInstance(cls, moduleName, className, constructor): + def createObjectInstance(cls, moduleName, className, constructor, importPath=None): logger = LoggingManager.getInstance().getLogger(cls.__name__) logger.debug('Creating object: %s, %s, %s' % (moduleName, className, constructor)) + if importPath is not None: + # Add import path if it was provided + sys.path.append[importPath] + cmd = 'from %s import %s' % (moduleName, className) exec cmd cmd = 'objectInstance = %s' % (constructor) exec cmd + + if importPath is not None: + # Remove import path that was added + del sys.path[-1] return objectInstance