ObjectLoader

An utility to load modules and objects in DIRAC and extensions, being sure that the extensions are considered

class DIRAC.Core.Utilities.ObjectLoader.ObjectLoader(baseModules=False)

Bases: object

Class for loading objects. Example:

from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader ol = ObjectLoader() ol.loadObject(‘TransformationSystem.Client.TransformationClient’)

__init__(baseModules=False)

init

getObjects(modulePath, reFilter=None, parentClass=None, recurse=False)

Search for modules under a certain path

modulePath is the import string needed to access the parent module. Root modules will be included automatically (like DIRAC). For instance “ConfigurationSystem.Service”

reFilter is a regular expression to filter what to load. For instance “.*Handler” parentClass is a class object from which the loaded modules have to import from. For instance RequestHandler

instance = None
loadModule(importString, hideExceptions=False)

Load a module from an import string

loadObject(importString, objName=False, hideExceptions=False)

Load an object from inside a module

reloadRootModules()

Retrigger the initialization of the rootModules.

This should be used with care. Currently, its only use is (and should stay) to retrigger the initialization after the CS has been fully initialized in LocalConfiguration.enableCS