pydio.injector - Dependency injector

class pydio.injector.Injector(provider: IUnboundFactoryRegistry, env: Optional[Hashable] = None)

Bases: IInjector

Dependency injector main class.

Parameters
  • provider – Unbound factory provider to work on

  • env

    Name of the environment this injector will use when making queries to IUnboundFactoryRegistry object given via provider.

    This can be obtained f.e. from environment variable. Once injector is created you will not be able to change this.

    See IUnboundFactoryRegistry.get() for more details.

exception AlreadyClosedError(**kwargs)

Bases: InjectorError

Raised when operation on a closed injector was performed.

exception NoProviderFoundError(key, env)

Bases: InjectorError

Raised when there was no matching provider found for given key.

Parameters
  • key – Searched key

  • env – Searched environment

exception OutOfScopeError(key, scope, required_scope)

Bases: InjectorError

Raised when there was attempt to create object that was registered for different scope.

Parameters
  • key – Searched key

  • scope – Injector’s own scope

  • required_scope – Required scope

close() Optional[Awaitable[None]]

See pydio.base.IInjector.close().

property env: Optional[Hashable]

Environment assigned to this injector.

inject(key)

See IInjector.inject.

is_closed() bool

Return True if this injector was closed or False otherwise.

scoped(scope: Hashable, env: Optional[Hashable] = None) IInjector

See pydio.base.IInjector.scoped().