Package pyamf :: Package util :: Module imports

[hide private]
[frames] | no frames]

# Module imports

source code

Tools for doing dynamic imports.

Since: 0.3

Classes | [hide private]

| ModuleFinder This is a special module finder object that executes a collection of callables when a specific module has been imported.

Functions | [hide private]

run_hooks(name, module) Run all hooks for a module. | source code

split_module(name) Splits a module name into its parent and child parts. | source code

when_imported(name, hook) Call `hook(module)` when module named `name` is first used. | source code

Variables | [hide private]

| post_load_hooks = `{}` A list of callables to be executed when the module is imported.
| loaded_modules = ``[``'``decimal``'``,` `'``collections``'``,` `'``django.utils.tran``...`` List of modules that have already been loaded.

Imports: sys

Function Details | [hide private]

### run_hooks(name, module)

source code

Run all hooks for a module. Load an unactivated "lazy" module object.

### split_module(name)

source code

Splits a module name into its parent and child parts.

    >>> split_module('foo.bar.baz')
    'foo.bar', 'baz'
    >>> split_module('foo')
    None, 'foo'

### when_imported(name, hook)

source code

Call `hook(module)` when module named `name` is first used.

'hook' must accept one argument: the module object named by 'name', which must be a fully qualified (i.e. absolute) module name. The hook should not raise any exceptions, or it will prevent later hooks from running.

If the module has already been imported normally, 'hook(module)' is called immediately, and the module object is returned from this function. If the module has not been imported, then the hook is called when the module is first imported.

Variables Details | [hide private]

### loaded_modules

List of modules that have already been loaded.

Value:

      ['decimal',
       'collections',
       'django.utils.translation',
       'sets',
       'sqlalchemy.orm',
       'sqlalchemy.orm.collections']