Attachment

class dsviper.Attachment

Bases: object

Binds a key type - a concept, a club or any_concept - to a document type, registered in a Definitions.

From it, keys are minted and documents created. It holds no document: a store does, and AttachmentGetting reads one by attachment and key.

An attachment compares, orders and hashes by its runtime_id, which its definition determines: two declaring the same namespace, name, key type and document type are equal however they were obtained, so one can key a dict, join a set or be sorted.

Note: Not directly instantiable.

create_document() → Value

Return a new document.

create_key(instance_id: ValueUUId | None = None) → ValueKey

Return a key for this attachment, naming the instance instance_id, or a fresh instance when it is None.

create_structure(initial_value: dict[str, _InputValues] | None = None) → ValueStructure

Return a new document of this attachment’s document type.

initial_value fills it in; raise if it does not fit the type.

description(*, namespace: NameSpace | None = None) → str

Return the attachment rendered for display.

With namespace, every name is written relative to it. Without, the key and document types are written relative to the attachment’s own namespace, and the attachment’s name in full.

document_type() → Type

Return the type of the document.

documentation() → str

Return the documentation the attachment was created with, empty when none was given.

identifier() → str

Return the identifier, unique among the attachments: the attachment’s namespace, its key type written relative to that namespace, and its name. App::User.profile for an attachment profile of namespace App on a concept User of App; App::Lib::User.profile when the concept is Lib’s; App::any_concept.tag for a key any_concept.

key_type() → _AbstractionTypes

Return the type of the key.

key_type_name() → TypeName

Return the key’s TypeName.

keys_type() → TypeSet

Return the set<key> type a whole key listing has.

optional_document_type() → TypeOptional

Return optional<document_type>: the type of what get() answers.

representation(*, namespace: NameSpace | None = None) → str

Return the declaration as text, qualified against namespace when one is given.

runtime_id() → ValueUUId

Return the uuid identifying this attachment.

It is computed from what the attachment is, so the same declaration yields the same id in any Definitions. Definitions says what each kind is computed from.

type_key() → TypeKey

Return the type key<element_type>.

type_name() → TypeName

Return the attachment’s namespace and name, App::profile.

It is not unique: two attachments of one name over different key concepts share it. identifier() is the unique address, App::User.profile.