djblets.registries.importer¶
Import utilities for registries.
- lazy_import_registry(module_path, registry_name, **kwargs)¶
Lazily import and construct a registry on access.
This is useful for providing registry instances in a Django app’s
__init__.py
file without needing to import other modules that might interfere with the Django initialization process. When accessed for the first time, the registry will be imported and constructed.This can also speed up the startup process, depending on the complexity of registries.
Importing and creation of registries is thread-safe. If two threads try to access a registry for the first time at the same time, they’ll both receive the same instance.
Changed in version 5.0: This is now thread-safe.
- Parameters:
- Returns:
A wrapper that will dynamically load and forward on to the registry.
- Return type:
django.utils.functional.SimpleLazyObject