Package elisa :: Package core :: Package components :: Module resource_provider :: Class ResourceProvider

Class ResourceProvider

source code


Responsible for accessing resources following REST architecture principles.

Accessing a resource is done through a URI that points to it. Possible operations on resources are defined by the REST principles and allow retrieval, creation, update and removal of resources.

For more information about REST, Roy Fielding's thesis is helpful: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

A resource can be identified with a URI. This is also called a pointer or a link.

Example:

You could have a list of music albums stored at some place designated by the following URI:

   elisa://localhost/albums

When the user decides to access the resource behind this URI, a retrieval request is sent to the elisa.resource_manager.ResourceManager. It holds all the ResourceProviders and forwards the request to one that can handle it. This is made possible by trying to match the URI to their regular expressions.

A resource in Elisa is stored as a elisa.core.components.model.Model. The chosen ResourceProvider returns the Model (in this example, it would be something like an AlbumsListModel) and starts to fill it asynchronously. When it is complete, the elisa.core.utils.defer.Deferred is fired.

Instance Methods
tuple of elisa.core.components.model.Model elisa.core.utils.defer.Deferred
get(self, uri, context_model=None)
Return a resource that uri is pointing to.
source code
elisa.core.utils.defer.Deferred
post(self, uri, **parameters)
Update the resource pointed by uri with parameters.
source code
elisa.core.utils.defer.Deferred
put(self, source_uri, container_uri, source_model=None)
Put one resource into another.
source code
elisa.core.utils.defer.Deferred
delete(self, uri)
Delete a Resource represented by a URI.
source code

Inherited from extern.log.log.Loggable: debug, doLog, error, info, log, logFunction, logObjectName, warning, warningFailure

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Inherited from component.Component
twisted.internet.defer.Deferred
clean(self)
Clean the component.
source code
twisted.internet.defer.Deferred
initialize(self, **kwargs)
Initialize the component.
source code
 
name__get(self) source code
 
name__set(self, value) source code
    Inherited from log.Loggable
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
Class Methods
    Inherited from component.Component
elisa.core.component.Component or a subclass
create(cls, config_section=None, **kwargs)
Create and initialize the component.
source code
Class Variables
str supported_uri
regular expression defining what URIs a ResourceProvider can handle

Inherited from extern.log.log.Loggable: logCategory

    Inherited from component.Component
  config_doc = {}
  default_config = {}
  name = property(fget= name__get, fset= name__set)
  path = PathDescriptor()
Properties

Inherited from object: __class__

Method Details

get(self, uri, context_model=None)

source code 

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 (elisa.core.media_uri.MediaUri) - URI pointing to the resource
  • context_model (elisa.core.components.model.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.
Returns: tuple of elisa.core.components.model.Model elisa.core.utils.defer.Deferred
a new model and a deferred fired when the model is fully loaded

post(self, uri, **parameters)

source code 

Update the resource pointed by uri with parameters.

Parameters:
Returns: elisa.core.utils.defer.Deferred
a deferred fired when the parameters got posted

put(self, source_uri, container_uri, source_model=None)

source code 

Put one resource into another. Both resources are identified with URIs.

Parameters:
  • source_uri (elisa.core.media_uri.MediaUri) - URI pointing to the resource that should be put into the other one
  • container_uri (elisa.core.media_uri.MediaUri) - URI pointing to the resource that should receive the resource
  • source_model (elisa.core.components.model.Model) - Often the resource behind the source_uri is already existing as a model-representation. To prevent from doing a 'get' for the given source_uri this model can also be given to the put request.
Returns: elisa.core.utils.defer.Deferred
a deferred fired when the resource got put

delete(self, uri)

source code 

Delete a Resource represented by a URI.

Parameters:
Returns: elisa.core.utils.defer.Deferred
a deferred fired when the resource got deleted