stapel-attributes
Typed attributes engine: an L1 library (no models, migrations, views, urls, comm surface or service identity of its own) providing a polymorphic type-plugin system (config/dto/dao/type per feature type) behind an open registry, nine built-in types, DTO/DAO validation and normalization, polymorphic DRF serializers with OpenAPI schemas, and a schema-driven (Lit 3) admin config editor. Imported directly by stapel-categories (feature schema) and stapel-listings (value validation).
Part of the Stapel framework — composable Django apps that deploy as a monolith or as microservices without changing module code.
Install
pip install stapel-attributes
At a glance
| Fact | Value |
|---|---|
| Version | 0.4.7 |
| Python | >=3.11 (3.11, 3.12, 3.13, 3.14) |
| Django | djangorestframework>=3.14 |
| Config axes | 1 |
| Usage surface | 36 |
| Extension points | 4 |
| Fleet dependencies | stapel-core |
Documentation
capabilities.json · llms.txt (for agents)
What this is
This is an L1 library, not a module: it ships no models, migrations,
views, urls or comm surface. Both stapel-categories (attribute schema) and
stapel-listings (attribute values) import it — the code both need
synchronously lives one layer down, like stapel-core itself.
Provenance: port of the categories/feature_types engine and the
ads validation pipeline from a legacy catalog app (see CHANGELOG for what
was fixed in transit).
Quick start
No INSTALLED_APPS entry, no urls — just import it:
from stapel_attributes import (
FeatureDef,
validate_dto,
normalize_to_dao,
validate_dto_structured,
)
configs = [
FeatureDef(slug="mileage", config={"type": "int", "min": 0, "postfix": "km"}),
FeatureDef(slug="condition", config={"type": "bool"}, mandatory=True),
]
payload = {"mileage": {"type": "int", "value": 120000},
"condition": {"type": "bool", "value": True}}
validate_dto(configs, payload) # raises ValidationError on failure
dao = normalize_to_dao(configs, payload) # {"mileage": {"type": "int", "value": 120000, "postfix": "km", "order": 0}, ...}
result = validate_dto_structured(configs, payload) # machine-readable batch result
Built-in types
int, float, string, bool, hex_color, select, date, header,
hierarchical_select, convertible_unit. Each type is a plugin: a Config
dataclass (schema), a DTO (client input), a DAO (stored value + display
metadata) and a handler (BaseFeatureType[TConfig, TDto, TDao]).
convertible_unit stores values in a canonical base unit per family
(length/weight/area/volume/temperature) and converts to/from the user-facing
unit — see MODULE.md for the storage/conversion/range-filter contract.
Other marketplace-specific types (size grids, ...) are not shipped — hosts register their own via the open registry (see MODULE.md for the worked example).
Settings
All configuration lives in the STAPEL_ATTRIBUTES namespace (dict setting,
flat setting, or env var — resolved lazily):
| Key | Default | Meaning |
|---|---|---|
EXTRA_TYPES |
[] |
Dotted paths of extra feature types, merged over the built-ins (each entry: a BaseFeatureType subclass or a module that registers types on import). |
Structured validation
Every validation failure carries a machine code end-to-end
(ValidationErrorCode) via FeatureValidationError — no message parsing.
Batch validators return ValidationBatchResult rows with error,
ref_value, localizable_error (an error.400.feature_* key) and params.
Extension points
See MODULE.md — the agent-facing map of every fork-free seam (settings, the type registry, serializer factories, translation-key hooks).
Admin UI
A schema-driven config editor (Lit 3 web components) ships with the package.
Each type declares its admin form in Python (config_form() → field-kinds); the
committed bundle renders it, so a new type needs zero JS for standard kinds. Use
ConfigEditorWidget on a config JSONField:
from stapel_attributes import ConfigEditorWidget
class FeatureForm(forms.ModelForm):
class Meta:
widgets = {"config": ConfigEditorWidget()}
Two themes (--stapel-*, light + dark), en/ru locales (merge without fork via
ADMIN_LOCALES), and JS widget registries for exotic types. See MODULE.md
"Admin UI" and docs/done/attributes-admin-ui.md. Frontend source is in static_src/
(npm test / npm run build); the built bundle is committed — consumers need no
Node.
Development
pip install -e . && pip install pytest pytest-django ruff
./setup-hooks.sh
pytest tests/
License
MIT — see LICENSE.
This page is assembled by stapel-readme from docs/readme.md plus the contract artifacts in docs/. Edit the prose in docs/readme.md; the badges, facts and links above and below it are generated — do not hand-edit README.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stapel_attributes-0.4.7.tar.gz.
File metadata
- Download URL: stapel_attributes-0.4.7.tar.gz
- Upload date:
- Size: 112.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bcc02cb329bb355bc16e013ecbb5a99ee71dc87a28ed0d5dd0d3504c133cceb
|
|
| MD5 |
42c28068b7550a960334cc13a2ae56d4
|
|
| BLAKE2b-256 |
40d283970418cdfd24a49efd0637cde4efdf07930a4a91ef7b3ed446f5b304d8
|
Provenance
The following attestation bundles were made for stapel_attributes-0.4.7.tar.gz:
Publisher:
publish.yml on usestapel/stapel-attributes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stapel_attributes-0.4.7.tar.gz -
Subject digest:
1bcc02cb329bb355bc16e013ecbb5a99ee71dc87a28ed0d5dd0d3504c133cceb - Sigstore transparency entry: 2557057188
- Sigstore integration time:
-
Permalink:
usestapel/stapel-attributes@a45bfa1e2e9869bdf4d0e2f43d439581d39ced70 -
Branch / Tag:
refs/tags/v0.4.7 - Owner: https://github.com/usestapel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a45bfa1e2e9869bdf4d0e2f43d439581d39ced70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file stapel_attributes-0.4.7-py3-none-any.whl.
File metadata
- Download URL: stapel_attributes-0.4.7-py3-none-any.whl
- Upload date:
- Size: 152.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f0848ceb506511c61f97fc2b5b22b5947b9180c77d4bfb000027dc4e3e30ddb
|
|
| MD5 |
7883019dbc1c6d54e7e725f3bcd56bd1
|
|
| BLAKE2b-256 |
a91dcb9f8d73fd5ae0adce675db59b62dc61706336890e2ffd3deba7aef8bb68
|
Provenance
The following attestation bundles were made for stapel_attributes-0.4.7-py3-none-any.whl:
Publisher:
publish.yml on usestapel/stapel-attributes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stapel_attributes-0.4.7-py3-none-any.whl -
Subject digest:
1f0848ceb506511c61f97fc2b5b22b5947b9180c77d4bfb000027dc4e3e30ddb - Sigstore transparency entry: 2557057209
- Sigstore integration time:
-
Permalink:
usestapel/stapel-attributes@a45bfa1e2e9869bdf4d0e2f43d439581d39ced70 -
Branch / Tag:
refs/tags/v0.4.7 - Owner: https://github.com/usestapel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a45bfa1e2e9869bdf4d0e2f43d439581d39ced70 -
Trigger Event:
push
-
Statement type: