Python API

django_load.core

django_load.core.load(modname, verbose=False, failfast=False)

Loads modules from all installed apps.

Parameters:
  • modname (string) – Name of the module (eg: 'plugins')
  • verbose (boolean) – If true, the loading will be verbose. Useful for debugging.
  • failfast (boolean) – If true, the loading will not surpress exceptions.
Return type:

None

django_load.core.iterload(modname, verbose=False, failfast=False)

Same as load() but returns an iterator of the loaded modules.

Parameters:
  • modname (string) – Name of the module (eg: 'plugins')
  • verbose (boolean) – If true, the loading will be verbose. Useful for debugging.
  • failfast (boolean) – If true, the loading will not surpress exceptions.
Return type:

iterator of modules

django_load.core.load_object(import_path)

Loads an object from an ‘import_path’, like in MIDDLEWARE_CLASSES and the likes.

Import paths should be: “mypackage.mymodule.MyObject”. It then imports the module up until the last dot and tries to get the attribute after that dot from the imported module.

If the import path does not contain any dots, a TypeError is raised.

If the module cannot be imported, an ImportError is raised.

If the attribute does not exist in the module, a AttributeError is raised.

Parameters:import_path (string) – The path to the object to load, eg 'mypackage.mymodule.MyObject'
Return type:object
django_load.core.iterload_object(import_paths)

Same as load_object() but for multiple import paths at once.

Parameters:import_paths (iterable of strings) – An iterable containing import_paths for load_object().
Return type:iterator of objects