ImportManager

ImportManager

Manages imported modules and protects against concurrent imports.

Keeps lists of all imported Python modules and templates as well as other config files used by Webware for Python. Modules which are not directly imported can be monitored using hupper. This can be used to detect changes in source files, templates or config files in order to reload them automatically.

class ImportManager.ImportManager(*args, **kwargs)

Bases: object

The import manager.

Keeps track of the Python modules and other system files that have been imported and are used by Webware.

__init__()

Initialize import manager.

delModules(includePythonModules=False, excludePrefixes=None)

Delete imported modules.

Deletes all the modules that have been imported unless they are part of Webware. This can be used to support auto reloading.

fileList(update=True)

Return the list of tracked files.

fileUpdated(filename, update=True, getmtime=<function getmtime>)

Check whether file has been updated.

findSpec(name, path, fullModuleName=None)

Find the module spec for the given name at the given path.

getReloader()

Get the current reloader if the application is monitored.

moduleFromSpec(spec)

Load the module with the given module spec.

notifyOfNewFiles(hook)

Register notification hook.

Called by someone else to register that they’d like to know when a new file is imported.

recordFile(filename, isfile=<function isfile>)

Record a file.

recordModule(module, isfile=<function isfile>)

Record a module.

recordModules(moduleNames=None)

Record a list of modules (or all modules).

updatedFile(update=True, getmtime=<function getmtime>)

Check whether one of the files has been updated.

watchFile(path, moduleName=None, getmtime=<function getmtime>)

Add more files to watch without importing them.