# Class e.c.r.ResourceManager(Manager):

Part of elisa.core.resource_manager View In Hierarchy

Provide access to resources through the use of ResourceProvider components which make use of various data sources.

Line # | Kind | Name | Docs
--- | --- | --- | ---
57 | Method | __init__ | Initialize resource providers
65 | Method | register_component | Register a new Component
73 | Method | unregister_component | Unregister a component from the Manager
84 | Method | get_resource_provider_by_path | Return the registered resource provider that corresponds to the given
139 | Method | get | Return a resource that `uri` is pointing to. A URI can point to
168 | Method | post | Update the resource pointed by `uri` with `parameters`.
185 | Method | put | Put one resource into another. Both resources are identified with URIs.
213 | Method | delete | Delete the resource that `uri` is pointing to.

Inherited from Manager:

Line # | Kind | Name | Docs
--- | --- | --- | ---
63 | Method | load_components | Load a list of components in sequence.
105 | Method | start | Start a loop or something to initialize the Manager. Can
112 | Method | stop | Stop clean and remove all registered components.

def __init__(self):
overrides elisa.core.manager.Manager.__init__
Initialize resource providers

def register_component(self, component):
overrides elisa.core.manager.Manager.register_component

Register a new Component

Store a new Component in our components list. Returns the result of the operation. If the component is already registered, don't register it twice.

Parameters | component | the Component to register (type: `elisa.core.component.Component` )
Raises | AlreadyRegistered | when the component has already been registered
| TypeError | when the given `component` is *not* of the type `supported_components`

def unregister_component(self, component):
overrides elisa.core.manager.Manager.unregister_component

Unregister a component from the Manager

Remove the Component instance from our components list if it's there. Returns the result of the operation.

Parameters | component | the Component to register (type: `elisa.core.component.Component` )
Raises | CannotUnregister | raised when the component cannot be removed

def get_resource_provider_by_path(self, path):

Return the registered resource provider that corresponds to the given component path.

This method should not be called to gain direct access to a resource provider, it is meant to be called only by capabilities at initialization time (capabilities need a reference to their "parent" resource provider).

Parameters | path | the full component path for the resource provider (type: `str` )

def get(self, uri, context_model=None):

Return a resource that `uri` is pointing to. A URI can point to any kind of resource. Resources are returned as models.

The model that is returned does not always already contain all the resource. The deferred is fired when the resource loading is complete.

Parameters | uri | URI pointing to the resource (type: `elisa.core.media_uri.MediaUri` )
| context_model | the URI often comes from a certain context. For example a URI pointing to a MusicAlbum can come from a Model that could contain the album cover or the album name. If the context_model is provided the resource_provider should try to reuse its data if possible. (type: `elisa.core.components.model.Model` )
Returns | a new model and a deferred fired when the model is fully loaded (type: tuple of `elisa.core.components.model.Model` `elisa.core.utils.defer.Deferred` )
Raises | NoMatchingResourceProvider | in case no ResourceProvider has a matching regular expression for `uri`

def post(self, uri, **parameters):
Update the resource pointed by `uri` with `parameters`.

Parameters | uri | URI pointing to the resource to update (type: `elisa.core.media_uri.MediaUri` )
| parameters | parameters of the resource that should be updated
Returns | a deferred fired when the parameters got posted (type: `elisa.core.utils.defer.Deferred` )
Raises | NoMatchingResourceProvider | in case no ResourceProvider has a matching regular expression for `uri`

def put(self, source_uri, container_uri, source_model=None):
Put one resource into another. Both resources are identified with URIs.

Parameters | source_uri | URI pointing to the resource that should be put into the other one (type: `elisa.core.media_uri.MediaUri` )
| container_uri | URI pointing to the resource that should receive the resource (type: `elisa.core.media_uri.MediaUri` )
| source_model | Often the resource behind the `source_uri` already exists as a Model. In order to avoid retrieving the resource pointed by `source_uri` that model can be passed to the put request (type: `elisa.core.components.model.Model` )
Returns | a deferred fired when the resource got put (type: `elisa.core.utils.defer.Deferred` )
Raises | NoMatchingResourceProvider | in case no ResourceProvider has a matching regular expression for the `container_uri`

def delete(self, uri):
Delete the resource that `uri` is pointing to.

Parameters | uri | URI pointing to the resource that should be deleted (type: `elisa.core.media_uri.MediaUri` )
Returns | a deferred fired when the resource got deleted (type: `elisa.core.utils.defer.Deferred` )
Raises | NoMatchingResourceProvider | in case no ResourceProvider has a matching regular expression for `uri`