application.factory Module

Instance creation and management.

class wpull.application.factory.Factory(class_map=None)[source]

Bases: collections.abc.Mapping, object

Allows selection of classes and keeps track of instances.

This class behaves like a mapping. Keys are names of classes and values are instances.

class_map

A mapping of names to class types.

instance_map

A mapping of names to instances.

is_all_initialized()[source]

Return whether all the instances have been initialized.

Returns:bool
new(name, *args, **kwargs)[source]

Create an instance.

Parameters:
  • name (str) – The name of the class
  • args – The arguments to pass to the class.
  • kwargs – The keyword arguments to pass to the class.
Returns:

instance

set(name, class_)[source]

Set the callable or class to be used.

Parameters:
  • name (str) – The name of the class.
  • class – The class or a callable factory function.