maxon.AssetRepositoryInterface

Description

An AssetRepositoryInterface manages a set of assets: - Assets can be looked up using their identifier and version. - New assets or new asset versions can be stored. - Each asset can have associated meta data which can be read and written. - Observers for changes to the repository can be added.

An asset repository can have several base repositories which are used for the lookup after lookup in the repository itself has finished. Cycles aren’t allowed, so asset repositories form a directed acyclic graph.

A repository which has another repository as (direct or indirect) base is said to be derived from that repository. Whenever an observable of a repository is triggered, this is done for all derived repositories too.

The methods of maxon.AssetRepositoryInterface are thread-safe. This allows for concurrent modifications and queries.

Methods Signature

AddBase(base)

Adds base to the list of base repositories of this repository.

CompareVersions(first, second)

Compares the versions of assets of this repository:

CopyAsset(aid, source[, addEncryption, …])

Copies an asset including meta data to this repository using the identifier aid for the copy.

DeleteAsset(aid)

Deletes the asset given by the identifier aid.

EraseAsset(asset)

Permanently erases an asset version.

FindAssets(assetType[, aid, version, …])

Finds all assets matching the parameters:

FindLatestAsset(type, aid, version, findMode)

Finds the asset with the given identifier in this repository and its base repositories.

FindRepository(repoId)

Finds the repository with the given identifier among this repository and its direct and indirect bases.

GetBases()

Returns an array holding all current base repositories of this repository.

GetDerived([receiver])

Yields all derived repositories of this repository to #receiver (those which have this repository as direct base).

GetDescription(asset)

returns the AssetDescription of the given asset.

GetDescriptionDatabaseId()

return

GetId()

Returns the identifier of this repository.

GetRepositoryName(language)

Returns the name of the repository in the requested language.

HandleDownloadStateChanged(repository, finished)

Informs all observers of ObservableDownloadStateChanged and calls HandleDownloadStateChanged on all derived repositories.

InitBases(bases)

Initializes the base repositories of this repository.

IsBasedOnOrSame(other)

Returns True if this repository is based on other or other itself, False otherwise.

IsWritable()

Tells if this repository is writable or not.

LoadDescriptionAssetId(category, language, …)

LoadDescriptionDefinition(mode, category, …)

param mode

OverwriteAsset(aid, asset[, metaData])

Stores asset as a new version using the identifier aid.

RemoveBase(base)

Removes base from the list of base repositories of this repository.

SetRepositoryName(name, language)

Sets the name of the repository in the given language.

StoreAsset(aid, asset[, metaData])

Stores asset as a new version using the identifier aid.

StoreMetaData(asset, metaId, data, kind)

Stores data for the meta data attribute metaId of the given asset.

StoreUrlMetaData(asset, metaId, data, kind)

Stores data for the meta data attribute metaId of the given asset.

Methods Definition

AssetRepositoryInterface.AddBase(base)

Adds base to the list of base repositories of this repository. The observers for ObservableBaseChanged of this repository and its derived repositories are informed.

Parameters

base (maxon.AssetRepositoryRef) – The base repository to add.

AssetRepositoryInterface.CompareVersions(first, second)

Compares the versions of assets of this repository:

Being newer isn’t based on the time stamp, but on the order in which assets are stored. It also takes into account the update counter (AssetBaseWithUpdateInterface.GetUpdate()) when both assets have the same version identifier.

If both assets have different asset identifiers the method returns maxon.COMPARERESULT.INCOMPARABLE. If the assets don’t belong to this repository, the result is unspecified.

Parameters
Returns

The result of the comparison of the versions.

Return type

maxon.COMPARERESULT

AssetRepositoryInterface.CopyAsset(aid, source, addEncryption=False, overwrite=False)

Copies an asset including meta data to this repository using the identifier aid for the copy.

source has to be an asset already stored in some repository.
The version identifier of source will be used for the copy even if this repository would normally derive a different identifier from the asset content.

Note

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
  • aid (maxon.Id) – The asset identifier to use.

  • source (maxon.AssetDescription) – The source asset to copy.

  • addEncryption (bool) – True if the copy shall be stored in an encrypted way. The encryption has to be handled by the maxon.AssetType.

  • overwrite (bool) – True to overwrite the existing asset.

Returns

The maxon.AssetDescription of the copy.

Return type

maxon.AssetDescription

AssetRepositoryInterface.DeleteAsset(aid)

Deletes the asset given by the identifier aid.

The previous versions still exist in the repository, this method just stores a delete marker so that AssetRepositoryInterface.FindAssets() doesn’t take those versions into account unless the ASSET_FIND_MODE.WITH_DELETED flag is given.

For a complete removal of a specific version use AssetRepositoryInterface.EraseAsset.().

Note

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters

aid (maxon.aid) – The asset to delete.

Returns

The maxon.AssetDescription which represents the delete marker.

Return type

maxon.AssetDescription

AssetRepositoryInterface.EraseAsset(asset)

Permanently erases an asset version.

Unlike AssetRepositoryInterface.DeleteAsset() which marks an asset as deleted but keeps all previous versions this method completely removes any data of the given asset version.

Note

Observers of ObservableAssetErased of this repository and its derived repositories are informed.

Parameters

asset (maxon.AssetDescription) – The asset version to erase from this repository.

AssetRepositoryInterface.FindAssets(assetType, aid=None, version=None, findMode=1, receiver=None)

Finds all assets matching the parameters:

When version is given or maxon.ASSET_FIND_MODE.LATEST is used and a matching asset is found in a repository, assets in base repositories thereof aren’t reported even if they are newer. So then an asset in a repository hides assets with the same identifier in base repositories. Assets with another identifier are still reported.

Parameters
Returns

If callback is None or a list then a list of maxon.AssetDescription otherwise False if callback cancelled further evaluation, True otherwise.

Return type

Union[list[maxon.AssetDescription], bool]

AssetRepositoryInterface.FindLatestAsset(type, aid, version, findMode)

Finds the asset with the given identifier in this repository and its base repositories. If version is set, this finds the asset with that version, otherwise it finds the latest asset. When a matching asset is found in a repository, assets in base repositories thereof aren’t considered even if they are newer

Parameters
Returns

The found asset, or a null reference.

Return type

maxon.AssetDescription

AssetRepositoryInterface.FindRepository(repoId)

Finds the repository with the given identifier among this repository and its direct and indirect bases. If no such repository exists, a null reference is returned, use Data.IsNullValue() to test it.

Parameters

repoId (maxon.Id) – The identifier of the repository to find.

Returns

The found repository, or a null reference.

Return type

maxon.AssetRepositoryRef

AssetRepositoryInterface.GetBases()

Returns an array holding all current base repositories of this repository.

Note

A repository must not have the same identifier as one of its (direct or indirect) bases.

Returns

The identifier of this repository.

Return type

maxon.BaseArray`[:class:`maxon.AssetRepositoryRef]

AssetRepositoryInterface.GetDerived(receiver=None)

Yields all derived repositories of this repository to #receiver (those which have this repository as direct base).

Parameters

receiver (Union[None, list, Callable[[maxon.AssetRepositoryRef], bool]]) – The receiver for derived repositories., return False to cancel further evaluation.

Returns

If receiver is None or a list then a list of maxon.AssetRepositoryRef otherwise False if callback cancelled further evaluation, True otherwise.

Return type

Union[list[maxon.AssetRepositoryRef], bool]

AssetRepositoryInterface.GetDescription(asset)

returns the AssetDescription of the given asset.

Parameters

asset (maxon.Asset) – Asset to query.

Returns

AssetDescription on success.

Return type

maxon.AssetDescription

AssetRepositoryInterface.GetDescriptionDatabaseId()
Returns

Return type

maxon.Id

AssetRepositoryInterface.GetId()

Returns the identifier of this repository. Repository identifiers needn’t be unique, but a repository must not have the same identifier as one of its (direct or indirect) bases.

Returns

The identifier of this repository.

Return type

maxon.Id

AssetRepositoryInterface.GetRepositoryName(language)

Returns the name of the repository in the requested language.

Parameters

language (maxon.LanguageRef) – Language to query.

Returns

Name on success.

Return type

str

AssetRepositoryInterface.HandleDownloadStateChanged(repository, finished)

Informs all observers of ObservableDownloadStateChanged and calls HandleDownloadStateChanged on all derived repositories.

Parameters
AssetRepositoryInterface.InitBases(bases)

Initializes the base repositories of this repository. This function may only be called once right after the maxon.AssetRepositoryInterface instance has been created.

Note

It doesn’t inform any observers.

Parameters

bases (maxon.Block [maxon.AssetRepositoryRef]) – The bases of this repository.

AssetRepositoryInterface.IsBasedOnOrSame(other)

Returns True if this repository is based on other or other itself, False otherwise.

Parameters

other (Union[maxon.AssetRepositoryRef, str, maxon.Id, maxon.String]) – A repository or a repository identifier.

Returns

True if other is a direct or indirect base of this repository or this repository itself.

Return type

bool

AssetRepositoryInterface.IsWritable()

Tells if this repository is writable or not.

Returns

True if this repository is writable, False otherwise.

Return type

bool

AssetRepositoryInterface.LoadDescriptionAssetId(category, language, dataType)
AssetRepositoryInterface.LoadDescriptionDefinition(mode, category, language, asset)
Parameters
Returns

Return type

DataDescriptionDefinition

AssetRepositoryInterface.OverwriteAsset(aid, asset, metaData=None)

Stores asset as a new version using the identifier aid.

Identifier, version and repository are set correspondingly at #asset, so asset may point to a copy of the original object afterwards (Asset is a copy-on-write reference).

Note

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
  • aid (maxon.Id) – The asset identifier to use.

  • asset (maxon.Asset) – The asset object to store. This method sets identifier, version and repository of asset.

  • metaData (Optional[maxon.AssetMetaData]) – Initial meta data to use for the asset.

Returns

The maxon.AssetDescription for the added asset.

Return type

maxon.AssetDescription

AssetRepositoryInterface.RemoveBase(base)

Removes base from the list of base repositories of this repository. The observers for ObservableBaseChanged of this repository and its derived repositories are informed. Nothing happens if this repository doesn’t have #base as one of its bases.

Parameters

base (maxon.AssetRepositoryRef) – The base repository to remove.

AssetRepositoryInterface.SetRepositoryName(name, language)

Sets the name of the repository in the given language.

Parameters
AssetRepositoryInterface.StoreAsset(aid, asset, metaData=None)

Stores asset as a new version using the identifier aid.

Identifier, version and repository are set correspondingly at #asset, so asset may point to a copy of the original object afterwards (Asset is a copy-on-write reference).

Note

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
  • aid (maxon.Id) – The asset identifier to use.

  • asset (maxon.Asset) – The asset object to store. This method sets identifier, version and repository of asset.

  • metaData (Optional[maxon.AssetMetaData]) – Initial meta data to use for the asset.

Returns

The maxon.AssetDescription for the added asset.

Return type

maxon.AssetDescription

AssetRepositoryInterface.StoreMetaData(asset, metaId, data, kind)

Stores data for the meta data attribute metaId of the given asset.

Note

Observers of ObservableMetaDataStored of this repository and its derived repositories are informed.

Parameters
AssetRepositoryInterface.StoreUrlMetaData(asset, metaId, data, kind)

Stores data for the meta data attribute metaId of the given asset.

Note

Observers of ObservableMetaDataStored of this repository and its derived repositories are informed.

Parameters