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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_module_news-0.0.5.tar.gz.
File metadata
- Download URL: simple_module_news-0.0.5.tar.gz
- Upload date:
- Size: 30.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
742c1d3eb3d54db0dd5d4d17c653e9d51c5c74e273398c92a3d223caaba23747
|
|
| MD5 |
198f9e3544c420c6b48ff5d2cd9c3547
|
|
| BLAKE2b-256 |
dcc8f29b38d0805bdefc5603a0d022907dc1148f35384532df6ee8c40da7ff90
|
Provenance
The following attestation bundles were made for simple_module_news-0.0.5.tar.gz:
Publisher:
release.yml on antosubash/smpy_modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_news-0.0.5.tar.gz -
Subject digest:
742c1d3eb3d54db0dd5d4d17c653e9d51c5c74e273398c92a3d223caaba23747 - Sigstore transparency entry: 2412705791
- Sigstore integration time:
-
Permalink:
antosubash/smpy_modules@e58b1165f3b0acaa0587a216d56d60143b36cbe8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e58b1165f3b0acaa0587a216d56d60143b36cbe8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file simple_module_news-0.0.5-py3-none-any.whl.
File metadata
- Download URL: simple_module_news-0.0.5-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e117b93613b4520d68ce9b5108a27b10855344a2635d0479644f1ef25d921f5f
|
|
| MD5 |
0f11f3f5614b301eaf7cdf6c824643c1
|
|
| BLAKE2b-256 |
35f988c7b4dcc35bf139737a7088dc51f396b43e624b1afc44faa3eaf2bc5c0c
|
Provenance
The following attestation bundles were made for simple_module_news-0.0.5-py3-none-any.whl:
Publisher:
release.yml on antosubash/smpy_modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_news-0.0.5-py3-none-any.whl -
Subject digest:
e117b93613b4520d68ce9b5108a27b10855344a2635d0479644f1ef25d921f5f - Sigstore transparency entry: 2412705967
- Sigstore integration time:
-
Permalink:
antosubash/smpy_modules@e58b1165f3b0acaa0587a216d56d60143b36cbe8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e58b1165f3b0acaa0587a216d56d60143b36cbe8 -
Trigger Event:
workflow_dispatch
-
Statement type: