Classes
PageInitializer
Ensures pages are correctly initialized with all required references.
Used by orchestrators after …
PageInitializer
Ensures pages are correctly initialized with all required references.
Used by orchestrators after creating pages to validate they're ready for use.
Design principles:
- Fail fast (errors at initialization, not at URL generation)
- Clear error messages (tell developer exactly what's wrong)
- Single responsibility (just validation, not creation)
- Lightweight (minimal logic, mostly checks)
Usage:
# In an orchestrator
def __init__(self, site):
self.initializer = PageInitializer(site)
def create_my_page(self):
page = Page(...)
page.output_path = compute_path(...)
self.initializer.ensure_initialized(page) # Validate!
return page
Methods 2
ensure_initialized
Ensure a page is correctly initialized.
Checks:
1. Page has _site reference (o…
ensure_initialized
def ensure_initialized(self, page: Page) -> None
Ensure a page is correctly initialized.
Checks:
- Page has _site reference (or sets it)
- Page has output_path set
- Page URL generation works
Parameters 1
page |
Page |
Page to validate and initialize |
ensure_initialized_for_section
Ensure a page is initialized with section reference.
Like ensure_initialized()…
ensure_initialized_for_section
def ensure_initialized_for_section(self, page: Page, section: Section) -> None
Ensure a page is initialized with section reference.
Like ensure_initialized() but also sets and validates the section reference. Used for archive pages and section index pages.
Parameters 2
page |
Page |
Page to validate and initialize |
section |
Section |
Section this page belongs to |
Internal Methods 1
__init__
Initialize the page initializer.
__init__
def __init__(self, site: Site)
Initialize the page initializer.
Parameters 1
site |
Site |
Site object to associate with pages |