Skip to main content

simple_module_news

News articles for SimpleModule hosts, backed by page-builder pages.

An article is a page. Its title, slug, body, approval workflow, revisions and public URL all belong to simple_module_pagebuilder; this module adds only the two things a page has no concept of — the category it belongs to and the date it should be listed under — plus the listing API and a feed block.

That is why there is no public route here. An article serves at /p/{slug} with the existing ETag, cache, CSP, SEO and site-layout handling; a second viewer would mean duplicating all of it.

Installation

pip install simple_module_news

The host must also install simple_module_pagebuilder. For an in-repo checkout, resolve it from the workspace:

dependencies = ["simple_module_news"]

[tool.uv.sources.simple_module_news]
workspace = true

Then run make migrate — the module's first revision is labelled news, so it can be removed on its own with alembic downgrade news@base.

Usage

Go to News in the sidebar. "New article" creates a page, attaches the article metadata to it, and drops you into the page-builder editor to write the body. Category and date are edited inline in the list.

To show articles on a page, add the News feed block in the page builder and set its category filter and item count.

API

Route Access
GET /api/news/articles?limit&offset&category&undated_first anonymous; published only
GET /api/news/categories anonymous; published only
POST /api/news/articles news.edit
PUT /api/news/articles/{id} news.edit
DELETE /api/news/articles/{id} news.edit

Reads are anonymous because the feed block runs on public pages. Listing is ordered newest first with undated articles last; undated_first=true flips the undated to the front, which is what the admin list uses so work in progress is not buried on the last page. An editor additionally sees articles whose page is still a draft. Each item carries page_status — the workflow state of the page behind it, which the admin list renders as a badge; without news.edit it is always published.

PUT is a partial update: a field you omit is left alone. Sending published_at as an explicit null is different from omitting it — that undates the article, which is a real state rather than an error.

DELETE detaches the metadata; the page and its body stay.

Design note: no foreign key

news_articles.page_id carries no database foreign key. The framework gives every module its own MetaData, so a cross-module ForeignKey cannot resolve its target table, and pagebuilder publishes no page-deleted event to hang a cascade on either.

Two things make that safe. Every listing inner-joins the page, so an article whose page was deleted stops appearing immediately rather than rendering a card that links nowhere. And the orphan is then removed rather than merely hidden — by a PageDeleted subscription first, and by a sweep at application startup when that event is missed.

The sweep is not belt-and-braces. The event bus logs a handler failure instead of raising it, and pagebuilder has already committed the page deletion by the time the handler runs, so a dropped event leaves the row behind with nothing to retry it. An invisible orphan does not stay invisible either: SQLite reuses a deleted row's id, so the row would re-attach to whatever page is created next and list one article's category and date against another article's page.

Development

uv sync --extra dev
uv run pytest

API-version contract

ModuleMeta.requires_framework declares which simple_module_core versions this module supports. Update the spec on each framework major bump after verifying compatibility.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_module_news-0.0.4.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_module_news-0.0.4-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file simple_module_news-0.0.4.tar.gz.

File metadata

  • Download URL: simple_module_news-0.0.4.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for simple_module_news-0.0.4.tar.gz
Algorithm Hash digest
SHA256 cc87fe25a3c2e1b7ff96d3e5ff042b48d538b5982e0eec85706d93cc6aaa1fa2
MD5 4bbf0bf381eb7f4e6e70de5359780cb5
BLAKE2b-256 865132a0e9eb7c42248720b6a0eb48b375801e28ded37474712354dc2956a455

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_news-0.0.4.tar.gz:

Publisher: release.yml on antosubash/smpy_modules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file simple_module_news-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_module_news-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f981df8afe4ed1f4a1005cefc0e018734685c0ab02fc469e93e86c82a7412d12
MD5 d4c573689a33dfbe7543402a8221f391
BLAKE2b-256 70914bf711fd1d74d3c20ce3f594b67ceca9884a8176c37257b0c828ff526668

See more details on using hashes here.

Provenance

The following attestation bundles were made for simple_module_news-0.0.4-py3-none-any.whl:

Publisher: release.yml on antosubash/smpy_modules

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.0.6

2 files

0.0.5

2 files

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

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