From ac975237e07f61d5969586ea0fc4f0b1f918a778 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Tue, 29 Sep 2026 18:04:58 +0100 Subject: Serve documents when a module keeps a collection, not by its inputs' names pure-serve took a module with an input named show or edit for a document app and refused it unless both were keyed messages: an app with a plain message named edit compiled and then would not start (review 004, an earlier P2). Documents are what a module keeps in a keyed collection; now the host serves them when the module declares one, and inputs named show and edit are otherwise messages as any other. check.py's server_plain_edit starts such an app and posts to edit. --- serve/serve.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'serve/serve.c') diff --git a/serve/serve.c b/serve/serve.c index 96e1b1d..e8b3ec3 100644 --- a/serve/serve.c +++ b/serve/serve.c @@ -2131,9 +2131,11 @@ static bool load_module(PureModule *m, const char *path, bool *documents, uint32 fprintf(stderr, "Module: %s\n", error); return false; } - /* Documents are served when the module has show and edit, as keyed messages. */ + /* Documents are served when the module keeps a keyed collection: its keyed + * messages show and edit read and write one by key. Without one, inputs + * named show and edit are messages as any other. */ int show = pure_module_input(m, "show"), edit = pure_module_input(m, "edit"); - *documents = show >= 0 || edit >= 0; + *documents = m->collections > 0; if (*documents && (show < 0 || edit < 0 || m->input[show].kind != PURE_KIND_MESSAGE || !m->input[show].keyed || m->input[edit].kind != PURE_KIND_MESSAGE || !m->input[edit].keyed)) { fputs("Module: documents need keyed messages named show and edit\n", stderr); -- cgit v1.2.3