aglyph.assembler — The Aglyph component assembler

The Aglyph assembler injects dependencies into application components.

Application components and their dependencies are defined in an aglyph.context.Context, which is used to initialize an assembler.

An assembler provides thread-safe caching of singleton component instances and borg component shared-states (i.e. instance __dict__ references).

class aglyph.assembler.Assembler(context)[source]

Bases: object

Create application objects using type 2 (setter) and type 3 (constructor) dependency injection.

context should be an aglyph.context.Context.

assemble(component_id)[source]

Return an instance of the component specified by component_id with all of its dependencies provided.

component_id must be a valid “relative_module.identifier” dotted-name string or a user-provided unique component identifier.

clear_singletons()[source]

Evict all cached singleton component instances.

Returns:a list of evicted component IDs
clear_borgs()[source]

Evict all cached borg component shared-states.

Returns:a list of component IDs corresponding to the evicted shared-state instance __dict__ references

Previous topic

aglyph — Dependency Injection for Python

Next topic

aglyph.binder — The Aglyph component binder

This Page