coherence.backends.models.containers (module) — Cohen3 0.8.0 documentation

# coherence.backends.models.containers (module)

## Backend models for Container

Backend container to be used as a container for backend items, used by backend store `BackendBaseStore`.

The BackendContainer inherits from `Container` and will initialize a `Container` stored into variable `BackendContainer.item`. This is the base class for our containers.

We also provide some more containers:

> - `BackendMusicAlbum`: Container which will contain audio items from an album
> - `BackendBasePlaylist`: Container which will contain items to be played

Note

To write this module, some of the the old backends has been taken as a reference:

> - `appletrailers_storage`
> - `lolcats_storage`
> - `banshee_storage`
> - `fs_storage`

Warning

Be aware that we use super to initialize all the classes of this module in order to have a better MRO class resolution…so…take it into account if you inherit from one of this classes.

New in version 0.8.3.

class `BackendContainer`(item_id, parent_id, name, **kwargs)

  Bases: `coherence.backend.Container`

  The BackendContainer will hold the reference to all your instances of BackendItem/s. This class could be used as a container for a simple backend. It is almost the same as a `Container` but with some slight differences that will make easier to create an inherited class form BackendContainer:

  > - The arguments to initialize the BackendContainer are
  > - When we initialize the BackendContainer we also create an attribute item whim will be of `Container` which will allow us to perform most of the operations we need to operate with your BackendItem/s

  `logCategory` = 'BackendContainer'
  `item_cls`

    alias of `coherence.upnp.core.DIDLLite.Container`

  `item` = None

    Define the initialized `item_cls`. It will be set when the class `BackendContainer` is initialized based on the attribute `item_cls`

class `BackendMusicAlbum`(item_id, parent_id, name, **kwargs)

  Bases: `coherence.backends.models.containers.BackendContainer`

  Definition for a music album. This is an inherited class from `BackendContainer` but we use a different item class `MusicAlbum` to create our item

  `logCategory` = 'BackendMusicAlbum'
  `item_cls`

    alias of `coherence.upnp.core.DIDLLite.MusicAlbum`

  `get_name`()

    Called by the MediaServer web.

    Returns: | the name of the item, it is always expected to be in unicode.

  `get_cover`()

    Called by the MediaServer web.

    Returns: | the filepath where to find the album art file

    Note

    only needed when we have created for that item an albumArtURI property that does point back to us.

class `BackendBasePlaylist`(item_id, parent_id, name, **kwargs)

  Bases: `coherence.backends.models.containers.BackendContainer`

  Definition for a playlist. This is an inherited class from `BackendContainer` but we use a different item class `PlaylistContainer` to create our item

  `logCategory` = 'BackendBasePlaylist'
  `item_cls`

    alias of `coherence.upnp.core.DIDLLite.PlaylistContainer`

  `get_name`()

    Called by the MediaServer web.

    Returns: | the name of the item, it is always expected to be in unicode.