UUIDRField
Resource field for storing UUID (Universally Unique Identifier) values.
UUIDRField is a specialized StrRField that automatically generates a unique UUID as the default value. Each Resource instance gets its own unique identifier.
This is useful for: - Unique identifiers for resources - Tracking and correlation IDs - External system references - Ensuring uniqueness across distributed systems
Storage behavior: - Stored in KV_STORE by default (inherited from StrRField) - Included in dict views by default - Automatically generates a new UUID if no value is set - UUID format: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Example: ```python class MyResource(Resource): # Automatically gets a unique UUID tracking_id = UUIDRField()
# Stored in DATABASE for searchability
external_id = UUIDRField(storage=RFieldStorage.DATABASE)
# Not included in dict view
internal_uuid = UUIDRField(include_in_dict_view=False)
# Usage
resource = MyResource()
print(resource.tracking_id) # e.g., "550e8400-e29b-41d4-a716-446655440000"
```
Note: - A new UUID is generated for each Resource instance - UUIDs are version 4 (random) by default - Cannot specify a default_value (always uses uuid.uuid4())
include_in_dict_view: boolstorage: RFieldStoragevalidator: ValidatorInitialize a UUIDRField that automatically generates unique identifiers.
Note: Unlike other fields, UUIDRField does not accept a default_value parameter as it always generates a new UUID for each instance.
bool - TrueRFieldStorage - RFieldStorage.KV_STOREDeserialize and validate a value from storage.
Validates the stored value using the field's validator before returning it.
AnyAnyGenerate a new UUID v4 as the default value.
This method is called each time a new Resource instance is created, ensuring that each instance gets a unique identifier.
AnySerialize and validate a value for storage.
Validates the value using the field's validator before storing it.
AnyAny