Skip to main content

MCMS Layouts

mcms_layouts provides reusable page layouts built on the MCMS RenderTree architecture. A layout defines the structural composition shared across multiple pages and identifies where individual page content should be inserted.

Layouts allow pages to share common structures such as headers, navigation, sidebars, footers, and content containers without duplicating those structures in every page.

Responsibilities

  • Define and manage reusable layout definitions.
  • Represent each layout using a RenderTree.
  • Identify the page-content injection point within a layout.
  • Provide layouts that can be associated with multiple pages.
  • Keep layout structure independent of individual page content.
  • Support layout reuse without sharing mutable render-node instances between pages.

Layout Architecture

A layout is a reusable definition containing a RenderTree.

The tree contains ordinary MCMS components, including structural components and an Empty component designated as the page-content placeholder.

LayoutDefinition
├── identifier
├── name
├── description
└── RenderTree
    ├── Header
    ├── Navigation
    ├── Empty (layout_content=True)
    └── Footer

The layout tree defines the shared page structure. It does not contain the actual content of an individual page.

Content Injection

Layouts use an Empty component to identify where page content should be injected.

The designated component is identified through its layout_content field:

layout_content = True

This is an instance-level property of the Empty component's render node. It distinguishes the content placeholder from other uses of the same component.

During composition, the page's content tree replaces the designated placeholder in the layout tree.

Example

A layout might contain:

Layout RenderTree
├── Header
├── Navigation
├── Empty (layout_content=True)
└── Footer

A page might contain:

Page RenderTree
├── Hero
├── About
└── Contact

After composition:

Composed RenderTree
├── Header
├── Navigation
├── Hero
├── About
├── Contact
└── Footer

The resulting tree is an ordinary RenderTree and can be processed by the existing rendering pipeline.

Layout Composition

The responsibility for combining layout and page trees belongs to mcms_render, which owns the RenderTree structure and its manipulation operations.

The composition process follows these steps:

  1. Retrieve the selected layout's RenderTree.
  2. Clone the layout tree to create an independent composition.
  3. Locate the Empty render node with layout_content=True.
  4. Clone the page's content tree.
  5. Replace the placeholder with the cloned page content.
  6. Return the composed RenderTree.

The original layout and page trees remain unchanged.

Composition must preserve the existing RenderTree invariants:

  • Unique node identifiers.
  • Valid node registry entries.
  • Correct parent-child relationships.
  • Consistent child ordering.
  • No shared node instances between independent trees.
  • No cycles.

Relationship with Pages

A page references a layout and maintains its own content RenderTree.

Page
├── Layout Reference
└── Content RenderTree

The layout remains independently managed and can be reused by multiple pages.

Changing a page's layout does not require modifying its content tree. Similarly, modifying page content does not modify the reusable layout definition.

The composed tree is produced separately from the stored layout and page definitions.

Relationship with Templates

Layouts and templates serve different purposes:

Concept Responsibility
Layout Provides reusable structural composition surrounding page content
Template Provides reusable component composition that can be inserted into page content

A template is instantiated and absorbed into a page's content tree during authoring.

A layout is associated with a page and combined with its content tree during composition.

Architectural Integrations

Package Relationship
mcms_core Provides shared infrastructure and exception conventions
mcms_components Provides the components used to construct layouts, including structural components and Empty
mcms_render Owns the RenderTree model, cloning, insertion, and layout-page composition
mcms_pages Associates pages with layouts and maintains page content trees
mcms_templates Provides reusable authoring-time component compositions
mcms_editor Provides the authoring experience for creating and editing layouts

These relationships describe architectural responsibilities. Refer to the package's pyproject.toml for its actual direct Python dependencies.

Architectural Principles

1. Layouts are RenderTrees

A layout uses the same RenderTree representation as pages and templates. No separate layout-node or rendering model is introduced.

2. Layouts are reusable

A single layout can be associated with multiple pages without duplicating its structural definition.

3. Page content remains independent

The page owns its content tree, while the layout owns its structural tree.

4. Content injection is explicit

The Empty component with layout_content=True identifies the content injection point. Ordinary Empty components are not automatically treated as layout placeholders.

5. Composition does not mutate source trees

Layout-page composition operates on cloned trees. The original layout and page definitions remain unchanged.

6. The composed tree is a normal RenderTree

After composition, the resulting tree follows the same structural rules and rendering pipeline as any other MCMS RenderTree.

Dependencies

Architectural integrations

mcms_render is responsible for tree composition and manipulation. mcms_components provides the components used in layout definitions, while mcms_pages manages the association between pages and layouts.

Python distribution dependencies

All MCMS Packages rely on django

Development

Run the package tests from the repository root:

uv run pytest packages/mcms-layouts/tests

Run the repository-configured Ruff and mypy checks where applicable.

Future Considerations

Potential future capabilities include:

  • Multiple named content slots within a layout.
  • Layout inheritance or nested layout structures.
  • Layout-specific editor interfaces.
  • Layout previews.
  • Layout versioning and publishing.
  • Layout assignment rules based on page type or other page metadata.

Metadata

Release files for mcms-layouts 0.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for mcms-layouts 0.1.0
File Interpreter ABI Platform Actions
mcms_layouts-0.1.0-py3-none-any.whl Python 3 none any Details for mcms_layouts-0.1.0-py3-none-any.whl

Release files / mcms_layouts-0.1.0-py3-none-any.whl

Download URL mcms_layouts-0.1.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b45d9f13684755eed7ee0570dbe3c6ff7efa745fad4c62747374916461de384
BLAKE2b-256 checksum
How to use checksums
73a20256ad96a76a32023c482267cb2068d90cec531014afda78eb8399498032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"21.3","id":"virginia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for mcms-layouts 0.1.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.1.0 This release

1 release file 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