loom.core.locator

Locate one application from its configuration file.

load_application is the single entry point the Alembic environment, the command line and the schema tools share: it reads the file named by LOOM_CONFIG (or an explicit path), discovers the models the same way the server does, compiles them into a MetaData owned by the returned Application and builds the bootstrap declaration from the database section. A missing key raises ConfigError naming it; nothing is defaulted.

Functions

_bootstrap(schema)

_database_user(user, section)

_discover(discovery)

_ensure_on_path(code_path, config_dir)

_required(value, key)

_resolve_path(config_path)

_schema_name(name)

_scope_sources(schema, scoped)

load_application([config_path])

Load, discover and compile the application described by config_path.

Classes

Application(models, metadata, database, ...)

One application: its models compiled into their own metadata and its declarations.

DatabaseConfig(*, url[, schema])

The database section as the locator reads it.

SchemaConfig(*[, mode, ...])

The database.schema section; every name is absent until the product writes it.

_AppSection(*, name[, code_path, discovery])

_Discovery(*[, mode, interfaces, modules, ...])

_DiscoveryInterfaces(*[, modules, ...])

_DiscoveryManifest(*[, module])

_DiscoveryModules(*[, include])

_GroupsSection(*, readers, writers)

_RolesSection(*, owner, migrator)

_UserSection(*, login, access)

_VersionTablesSection(*, structure, data)

class loom.core.locator.SchemaConfig(*, mode='create_all', allow_unprotected_dialect=False, name=None, roles=None, database_users=None, scopes=None, guard=None, groups=None, version_tables=None, naming_convention=None)[source]

Bases: Struct

The database.schema section; every name is absent until the product writes it.

naming_convention is handed to the application’s MetaData as SQLAlchemy’s naming_convention, keyed by pk, fk, uq, ck and ix; absent, SQLAlchemy’s default applies.

Parameters:
  • mode (Literal['create_all', 'external'])

  • allow_unprotected_dialect (bool)

  • name (str | None)

  • roles (_RolesSection | None)

  • database_users (dict[str, _UserSection] | None)

  • scopes (dict[str, str] | None)

  • guard (str | None)

  • groups (_GroupsSection | None)

  • version_tables (_VersionTablesSection | None)

  • naming_convention (dict[str, str] | None)

class loom.core.locator.DatabaseConfig(*, url, schema=<factory>)[source]

Bases: Struct

The database section as the locator reads it.

Parameters:
class loom.core.locator.Application(models, metadata, database, bootstrap, scoped, scope_sources)[source]

Bases: object

One application: its models compiled into their own metadata and its declarations.

Parameters:
loom.core.locator.load_application(config_path=None)[source]

Load, discover and compile the application described by config_path.

Raises:

ConfigError – When the path is missing, a required key is absent or a value has the wrong shape; the message names the key.

Parameters:

config_path (str | None)

Return type:

Application