Message
Represent an actual message that can be stored in any of the supported storage classes (typically session- or cookie-based) and rendered in a view or template.
Attributes
| Attribute | Type | Description |
|---|---|---|
| level | int | Integer representing the severity level of the message, used to categorize and filter messages. |
| message | string | The actual text content of the message to be rendered in a view or template. |
| extra_tags | string | An optional string of custom CSS classes or identifiers to be applied to the message for styling or categorization. |
| tags | string | A space-separated string combining the level-specific tag and any extra tags for use in HTML class attributes. |
| level_tag | string | The string representation of the message level retrieved from the global LEVEL_TAGS mapping. |
Constructor
Signature
def Message(
level: int,
message: str,
extra_tags: str = None
)
Parameters
| Name | Type | Description |
|---|---|---|
| level | int | The severity level of the message (e.g., DEBUG, INFO, WARNING, ERROR, CRITICAL). |
| message | str | The actual content of the message. |
| extra_tags | str = None | An optional string of custom tags to associate with the message. |
Methods
tags()
@classmethod
def tags() - > string
Combines the message's level tag and any extra tags into a single space-separated string.
Returns
| Type | Description |
|---|---|
string | A space-delimited string of all CSS classes or tags associated with the message. |
level_tag()
@classmethod
def level_tag() - > string
Retrieves the string label corresponding to the message's numerical importance level.
Returns
| Type | Description |
|---|---|
string | The string representation of the message level, or an empty string if the level is not recognized. |