zope.deferredimport API

zope.deferredimport.initialize(level=1)[source]

Prepare a module to support deferred imports.

Modules do not need to call this directly, because the define* and deprecated* functions call it.

This is intended to be called from the module to be prepared. The implementation wraps a proxy around the module and replaces the entry in sys.modules with the proxy. It does no harm to call this function more than once for a given module, because this function does not re-wrap a proxied module.

The level parameter specifies a relative stack depth. When this function is called directly by the module, level should be 1. When this function is called by a helper function, level should increase with the depth of the stack.

Returns nothing when level is 1; otherwise returns the proxied module.

zope.deferredimport.define(**names)[source]

Define deferred imports using keyword parameters.

Each parameter specifies the importable name and how to import it. Use module:name syntax to import a name from a module, or module (no colon) to import a module.

zope.deferredimport.defineFrom(from_name, *names)[source]

Define deferred imports from a particular module.

The from_name specifies which module to import. The rest of the parameters specify names to import from that module.

zope.deferredimport.deprecated(message, **names)[source]

Define deferred and deprecated imports using keyword parameters.

The first use of each name will generate a deprecation warning with the given message.

Each parameter specifies the importable name and how to import it. Use module:name syntax to import a name from a module, or module (no colon) to import a module.

zope.deferredimport.deprecatedFrom(message, from_name, *names)[source]

Define deferred and deprecated imports from a particular module.

The first use of each name will generate a deprecation warning with the given message.

The from_name specifies which module to import. The rest of the parameters specify names to import from that module.