Skip to main content

platform-context

Shared platform foundation for all Django projects in the iil.pet ecosystem.

What it provides

  • Request Context — Thread-safe context propagation (tenant_id, user_id, request_id)
  • Multi-Tenancy Middleware — Subdomain-based tenant resolution + Postgres RLS
  • Audit Event Logging — Structured audit trail (model-agnostic)
  • Outbox Pattern — Reliable event publishing within transactions
  • Exception Hierarchy — Structured platform exceptions
  • Template Context Processors — Tenant/permission info in Django templates

Installation

pip install -e packages/platform-context

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "platform_context",
]

Usage

from platform_context import get_context, set_tenant, set_user_id
from platform_context.middleware import SubdomainTenantMiddleware
from platform_context.audit import emit_audit_event
from platform_context.exceptions import TenantNotFoundError

Configuration

Setting Default Description
TENANT_BASE_DOMAIN "localhost" Base domain for subdomain resolution
TENANT_MODEL "tenancy.Organization" Dotted path to tenant model
TENANT_SLUG_FIELD "slug" Field name for slug lookup
TENANT_ID_FIELD "tenant_id" Field name for tenant_id
TENANT_ALLOW_LOCALHOST False Allow admin access without tenant (dev)
PLATFORM_AUDIT_MODEL None Dotted path to AuditEvent model
PLATFORM_OUTBOX_MODEL None Dotted path to OutboxMessage model

Relation to bfagent-core

platform-context is the framework-agnostic foundation extracted from bfagent-core (see ADR-028). bfagent-core now depends on platform-context and re-exports its public API for backward compatibility.

New projects should depend on platform-context directly.

Metadata

Release files for iil-platform-context 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iil-platform-context 0.7.0
File Size Uploaded Provenance
iil_platform_context-0.7.0.tar.gz 40.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for iil-platform-context 0.7.0
File Interpreter ABI Platform
iil_platform_context-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 80.9 kB

Release files / iil_platform_context-0.7.0.tar.gz

Download URL iil_platform_context-0.7.0.tar.gz
Size 40.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7c75edc166a152ae17b274b042e4ac6119d229d75a44de7eb366a75879e42ca9
BLAKE2b-256 checksum
How to use checksums
038f996b4d1f977cf96c49d799f1a0b7d21d35c620ed5726b766c32347601ef6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / iil_platform_context-0.7.0-py3-none-any.whl

Download URL iil_platform_context-0.7.0-py3-none-any.whl
Size 40.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d16de129a2353bf9ae9a027db861ad43afb815928bd7f96fa91b933c8242b34a
BLAKE2b-256 checksum
How to use checksums
961c54f88a15b4c94b523238afa5819198ee0d6e58874cac5c805a047f1b4557
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for iil-platform-context 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page