Skip to main content

Tag

A label that can be attached to one or more bookmarks. Attributes: id: Unique identifier. name: Display name (must be unique per user). color: Visual colour for UI rendering. description: Optional description of what this tag represents. usage_count: Number of bookmarks currently using this tag.

Attributes

AttributeTypeDescription
idstringUnique identifier.
namestringDisplay name (must be unique per user).
color[TagColor](tagcolor.md?sid=app_models_tag_tagcolor) = TagColor.GRAYVisual colour for UI rendering.
descriptionstringOptional description of what this tag represents.
usage_countinteger = 0Number of bookmarks currently using this tag.

Constructor

Signature

def Tag(
name: str,
color: [TagColor](tagcolor.md?sid=app_models_tag_tagcolor) = TagColor.GRAY,
description: str
)

Parameters

NameTypeDescription
namestrThe display name of the tag.
color[TagColor](tagcolor.md?sid=app_models_tag_tagcolor) = TagColor.GRAYThe visual color for UI rendering.
descriptionstrAn optional description of what this tag represents.

Methods


rename()

@classmethod
def rename(
new_name: string
) - > None

Rename the tag. Raises ValueError if the name is empty or too long.

Parameters

NameTypeDescription
new_namestringThe new display name for the tag.

Returns

TypeDescription
NoneNone

increment_usage()

@classmethod
def increment_usage() - > int

Record that a bookmark now uses this tag. Returns the new usage count.

Returns

TypeDescription
intThe updated usage count after incrementing.

decrement_usage()

@classmethod
def decrement_usage() - > int

Record that a bookmark removed this tag. Returns the new usage count, ensuring it does not go below zero.

Returns

TypeDescription
intThe updated usage count after decrementing.

to_dict()

@classmethod
def to_dict() - > Dict[str, Any]

Serialise the tag object into a JSON-safe dictionary representation.

Returns

TypeDescription
Dict[str, Any]A dictionary containing the tag's id, name, color, description, and usage_count.

from_dict()

@classmethod
def from_dict(
data: Dict[str, Any]
) - > [Tag](tag.md?sid=app_models_tag_tag)

Construct a Tag object from a dictionary representation.

Parameters

NameTypeDescription
dataDict[str, Any]A dictionary containing the tag's properties, expected to have at least a 'name' key.

Returns

TypeDescription
[Tag](tag.md?sid=app_models_tag_tag)A new Tag object initialized with the provided dictionary data.