Skip to main content

Category tree for the Stapel framework

Project description

stapel-categories

CI codecov PyPI

Category tree with typed features for the Stapel framework — composable Django apps that deploy as a monolith or as microservices without changing module code.

A hierarchical category tree (django-treenode) and a parallel feature tree whose typed config is validated by stapel-attributes. Categories own the tree structure, feature inheritance, the ordered category↔feature M2M, and the feature-editor lifecycle; the attribute engine (types, config/DTO/DAO validation, polymorphic serializers, admin widgets) lives in stapel-attributes and is imported, never re-implemented.

Install

pip install stapel-categories
INSTALLED_APPS = [
    # ...
    "treenode",            # django-treenode (tree-cache signals)
    "stapel_categories",
]

# urls.py — the host chooses the prefix
path("categories/", include("stapel_categories.urls"))

stapel-attributes is an imported library (no app to install); its config editor ships static assets, so run collectstatic if you use the admin.

Settings

All configuration lives in the STAPEL_CATEGORIES namespace (dict setting, flat setting, or env var — resolved lazily):

Key Default Meaning
CAROUSEL_CACHE_TIMEOUT 300 Seconds the carousel response is cached.
FEATURE_DISPLAY_CACHE_TIMEOUT 60 Seconds an admin feature display label is memoized.
DISPLAY_TRANSLATOR stapel_categories.translation.identity_translator Dotted path (key)->str for rendering translation keys (default: identity).

comm surface

Kind Name Contract
Function categories.features {"category_id": int} -> {"category_id", "revision", "features":[{id,slug,name,mandatory,config}]} — resolved schema (own + inherited), cacheable by revision
Action (emit) category.changed {"category_id": int, "revision": int} on any category/feature mutation — for downstream cache invalidation

categories.features lets stapel-listings validate attribute values against a category's schema without importing this module.

Extension points

See MODULE.md — the agent-facing map of every fork-free seam (settings, serializer seams, comm surface, feature-editor actions, admin-UI pointer to stapel-attributes).

Development

pip install -e . && pip install pytest pytest-django ruff
./setup-hooks.sh
pytest tests/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stapel_categories-0.5.0.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stapel_categories-0.5.0-py3-none-any.whl (67.7 kB view details)

Uploaded Python 3

File details

Details for the file stapel_categories-0.5.0.tar.gz.

File metadata

  • Download URL: stapel_categories-0.5.0.tar.gz
  • Upload date:
  • Size: 89.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stapel_categories-0.5.0.tar.gz
Algorithm Hash digest
SHA256 de4e92de4fc4e9fff32272f3350fe0bcfe9f91a3fa7181a2dcfcc82b76afd2dc
MD5 ad0d2bdbb295bf3541461d5c27a8e092
BLAKE2b-256 56a30bb488b507027d46f1f01e98d310719f1d4cca13917dba18d01300d75bcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for stapel_categories-0.5.0.tar.gz:

Publisher: publish.yml on usestapel/stapel-categories

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stapel_categories-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stapel_categories-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f02b5d0a593c25092757640f6c3b2e007d1cc84040db88655ffcda5fb26bce7d
MD5 f0bfe64b1a1850dd9e1a9d07722bd109
BLAKE2b-256 53c0b6d08f4a5f06462e836ac558a8b33dcd160a5a6a784e5ceacc8558b1951c

See more details on using hashes here.

Provenance

The following attestation bundles were made for stapel_categories-0.5.0-py3-none-any.whl:

Publisher: publish.yml on usestapel/stapel-categories

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page