pydio.provider - Object factory provider

class pydio.provider.Provider

Bases: pydio.base.IUnboundFactoryRegistry

Used to record user-defined object factories or instances and bind them with particular key, that can later be used by IInjector.inject().

exception DoubleRegistrationError(key, env)

Bases: pydio.exc.ProviderError

Raised when same (key, env) tuple was used twice during registration.

Parameters
  • key – Registered key

  • env – Registered environment

property env
property key
attach(provider: pydio.provider.Provider)

Attach given provider to this provider.

This effectively extends current provider with object factories registered to the other one.

Use this if you need to split your providers across multiple modules.

get(key, env=None)

See IUnboundFactoryRegistry.get().

has_awaitables()

See IUnboundFactoryRegistry.has_awaitables().

provides(key, scope=None, env=None)

Same as register_func(), but to be used as a decorator.

Here’s an example:

from pydio.api import Provider

provider = Provider()

@provider.provides('spam')
def make_spam():
    return 'give me more spam'
register_func(key, func, scope=None, env=None)

Register user factory function.

Parameters
  • key

    Key to be used for func.

    See IInjector.inject() for more info.

  • func

    User-defined function to be registered.

    This can be normal function, coroutine, generator or async denerator.

  • scope – Optional scope to be assigned.

  • env – Optional environment to be assigned

register_instance(key, value, scope=None, env=None)

Same as register_func(), but for registration of constant objects.

If your application has some global configuration data you want to inject using PyDio - that’s the method you should use.