sams.sets – Internal Service for Sets

A set a collection of Assets. It is used as a way to organise and restrict access to the Assets it holds.

All access to the binary or metadata of assets will go through this service. There must be at least one Set configured in the system.

A single Set can be designated as the default Set. When access is requested to an asset without a set being provided, the default set will be used.


The Set service instance can be found under sams.sets.service and used all:

from sams.sets import get_service

def test_sets():
    sets_service = get_service()[{....}])
    sets_service.patch(set_id, {...})

This service instance can only be used after the application has bootstrapped.

Resource Schema

class SetsResource(endpoint_name, app, service, endpoint_schema=None)
schema =
_id bson.objectid.ObjectId

Globally unique id, generated automatically by the system.

state string (sams_client.schemas.sets.SET_STATES)

The state of the Set. One of draft, usable, or disabled.

name string

Unique name for the Set

description string

A short description on what this set is designated for

destination_name string

The name of a registered StorageDestination (

destination_config dict

A dictionary containing the configuration options for the specific destination used

maximum_asset_size long

The maximum size of an Asset that can be uploaded to this Set (optional)

endpoint_name: Optional[str] = 'sets'
internal_resource: bool = True
url: Optional[str] = 'internal/sets'


class SetsService(datasource: Optional[str] = None, backend=None)
validate_patch(original, updates)

Validates the Set on update

The following additional validation is performed on Sets being updated:
  • Once a set has changed from draft state, it can never return to draft

  • Once a set has changed from draft state, destination_name and

    destination_config cannot be changed

  • The destination_name must exist in a STORAGE_DESTINATION_ config attribute

  • original – The original document from the database

  • updates – A dictionary with the desired attributes to update


Superdesk.validation.ValidationError: if there are validation errors


Validate state on delete

Sets can only be deleted from the system if they are in the state SET_STATES.DRAFT.


doc – The Set to delete


Superdesk.validation.ValidationError: If the Set is not in SET_STATES.DRAFT state

get_max_asset_size(set_id: bson.objectid.ObjectId)int

Returns the maximum allowed size of an Asset for a Set

Based on the configured settings, this method returns:
  • Set.maximum_asset_size if MAX_ASSET_SIZE == 0

  • MAX_ASSET_SIZE if Set.maximum_asset_size == 0

  • Otherwise whichever is lowest


set_id (bson.objectid.ObjectId) – The ID of the Set


The configured MAX_ASSET_SIZE of Set.maximum_asset_size, whichever is lower

Return type