Module

config.url_policy

URL Ownership Policy Configuration.

This module defines reserved URL namespaces and ownership rules for URL coordination within Bengal sites. It's used by the URL registry and validation systems to prevent URL conflicts between user content and system-generated pages.

Reserved Namespaces:

  • /tags/: Taxonomy pages (owned by taxonomy system)
  • /search/: Search page (owned by special_pages)
  • /404/: Error page (owned by special_pages)
  • /graph/: Graph visualization (owned by special_pages)
  • Additional namespaces can be configured dynamically via autodoc settings

Module Attributes:

RESERVED_NAMESPACES: Base mapping of namespace prefixes to ownership metadata.

Key Functions:

get_reserved_namespaces: Get all reserved namespaces including dynamic autodoc prefixes.
is_reserved_namespace: Check if a URL falls within a reserved namespace.

Example:

>>> is_reserved_namespace("/tags/python/")

(True, 'taxonomy') >>> is_reserved_namespace("/blog/my-post/") (False, None)

See Also:

  • URL registry inbengal.core.url_registry: Uses policy for conflict detection.
  • Health validators: Check for namespace violations.

Functions

get_reserved_namespaces 1 dict[str, dict[str, Any]]
Get all reserved namespaces including dynamically configured prefixes. Returns…
def get_reserved_namespaces(site_config: dict[str, Any] | None = None) -> dict[str, dict[str, Any]]

Get all reserved namespaces including dynamically configured prefixes.

Returns the base reserved namespaces plus any additional namespaces configured through autodoc settings in the site configuration.

Parameters
Name Type Description
site_config dict[str, Any] | None

Site configuration dictionary. If provided, autodoc prefixes are extracted and added to the reserved namespaces.

Default:None
Returns
dict[str, dict[str, Any]]
is_reserved_namespace 2 tuple[bool, str | None]
Check if a URL falls within a reserved namespace. Examines the first path segm…
def is_reserved_namespace(url: str, site_config: dict[str, Any] | None = None) -> tuple[bool, str | None]

Check if a URL falls within a reserved namespace.

Examines the first path segment of the URL to determine if it matches any reserved namespace prefix.

Parameters
Name Type Description
url str

URL to check (e.g.,"/tags/python/", "/search/"). Leading and trailing slashes are normalized.

site_config dict[str, Any] | None

Site configuration dictionary. If provided, includes dynamically configured autodoc namespaces in the check.

Default:None
Returns
tuple[bool, str | None]