Skip to main content

Tag

A label that can be attached to one or more bookmarks.

Attributes

AttributeTypeDescription
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.
idstring = uuid.uuid4().hex[:8]Unique identifier.
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 = "",
id: str = uuid.uuid4().hex[:8],
usage_count: int = 0
) - > None

Parameters

NameTypeDescription
namestrThe display name of the tag.
color[TagColor](tagcolor.md?sid=app_models_tag_tagcolor) = TagColor.GRAYThe visual color assigned to the tag.
descriptionstr = ""An optional description of the tag.
idstr = uuid.uuid4().hex[:8]A unique identifier for the tag.
usage_countint = 0The initial number of bookmarks using this tag.

Methods


rename()

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

Rename the tag.

Parameters

NameTypeDescription
new_namestrThe new display name.

Returns

TypeDescription
None

increment_usage()

@classmethod
def increment_usage() - > int

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

Returns

TypeDescription
intThe updated usage count after incrementing.

decrement_usage()

@classmethod
def decrement_usage() - > int

Record that a bookmark removed this tag. Returns new count.

Returns

TypeDescription
intThe updated usage count after decrementing, ensuring it does not fall below zero.

to_dict()

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

Serialise to a JSON-safe dictionary.

Returns

TypeDescription
Dict[str, Any]A dictionary containing the tag's ID, name, color value, 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 from a dictionary.

Parameters

NameTypeDescription
dataDict[str, Any]The dictionary containing tag attributes like name, color, and description.

Returns

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