dlab_core.registry

Module Contents

CONTAINER_PARAM_CORE_CLI_ROUTERS = core.cli_router[source]
exception RegistryLoadException[source]

Bases: dlab_core.domain.exceptions.DLabException

register_context(key, value)[source]

Sets a parameter or an object. Objects must be defined as Closures. Allowing any python callable leads to difficult to debug problems as function names (strings) are callable (creating a function with the same name as an existing parameter would break your container).

Parameters:
  • key (str) – The unique identifier for the parameter or object.
  • value – The value or a closure of the parameter.
extend_context(key, call)[source]

Extends an object definition. Useful when you want to extend an existing object definition, without necessarily loading that object.

Parameters:
  • key (string) – The unique identifier for the parameter or object.
  • call (callable) – The passed callable.
Return type:

callable

Returns:

The wrapped callable.

freeze_context(key, call)[source]

Protects a callable from being interpreted as a service. This is useful when you want to store a callable as a parameter.

Parameters:
  • key (string) – The unique identifier for the parameter or object.
  • call (function) – A callable to protect from being evaluated.
Return type:

callable

Returns:

The passed callable.

get_resource(key)[source]

Returns the context resource at the specified index.

Parameters:key (string) – The unique identifier for the parameter or object.
Returns:Resource parameter or an object.
load_context()[source]

Initial Load base context resources.

reload_context()[source]

Reload base context resources.

do_action(name)[source]

This function invokes all functions attached to hook action. Hooks needs to have next naming convention <verb>.<noun>

Parameters:name (str) – Action name.
add_hook(name, call)[source]

Actions are the hooks that the core launches at specific points during execution, or when specific events occur. Plugins can specify that one or more of its Python functions are executed at these points, using the Action API. It is possible to create new action hooks by simply calling this function, specifying the name of the new hook using the name parameter. Hooks needs to have next naming convention <verb>.<noun>

Parameters:
  • name (str) – Action name.
  • call (callable) – Code automatically invokes whenever a special action occurs.