ferrosoft.apps.ferrobase.management package

Subpackages

Submodules

ferrosoft.apps.ferrobase.management.tenantcommand module

class ferrosoft.apps.ferrobase.management.tenantcommand.TenantAwareCommand(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: BaseCommand

Base class for management commands that operate on a single tenant database.

Adds a -T / --tenant argument. When a tenant name is supplied, the tenant database connection is activated and handle_tenant is called inside that context. Without a tenant name the master database is used and a warning is printed to stderr.

Subclasses must implement handle_tenant.

add_arguments(parser)[source]

Entry point for subclassed commands to add custom arguments.

handle(*args, **options)[source]

The actual logic of the command. Subclasses must implement this method.

handle_tenant(*args, **options)[source]

Execute command logic for the active tenant context.

Called by handle after activating the tenant database connection. self.tenant holds the active Tenant instance (or None when running against the master database).

Parameters:
  • *args – Positional arguments forwarded from the CLI parser.

  • **options – Keyword arguments forwarded from the CLI parser.

tenant: Tenant | None = None