Acorn API documentation for lib/guru, lib/secure, and lib/wgtauth
Summary
Acorn development documentation for lib/guru, lib/secure, and lib/wgtauth. Part of a push to create the underpinnings of an SDK to support Oak-Tree, Spatial Imaging, and Sonador engineering efforts — a consistent reference for building REST-like APIs on Django and consuming them from client applications so that adding a resource is a matter of following a known pattern rather than reinventing request parsing, validation, pagination, and auth.
This MR is the framework half of a two-repo documentation split. The Sonador/MedTech-specific application of these patterns (the Orthanc plugin view layer, viewer, streaming, and the Sonador IO client) lives in the companion MR oak-tree/medical-imaging/docs/platform!9 (merged) — oak-tree/medical-imaging/docs/platform!9 (merged). Both MRs address oak-tree/medical-imaging/imaging-development-env#56 (closed).
All reference pages below are grounded in the actual lib/ sources (lib/guru/views, lib/guru/forms, lib/guru/filter, lib/secure) and the Guru Client / example-client sources rather than inferred from naming.
New reference pages
-
dev.overview— "What Is Guru & Why" on-ramp: convention-over-configuration framing, who it's for (backend devs, integrators, AI agents), and how the pieces (models / views / forms / filters / security) fit together, with a request-flow diagram and a "fastest path" pointer into the quickstart. -
dev.forms— Forms & data validation: theGuruCoreFormsave pipeline (filterRelatedModelData→super().save→saveRelatedModelData),RelatedModelFieldvs.ManyToManyRelatedModelField(callbacks, M2M clear/re-add,related_model_field_validation_order),NestedFormField/MultipleNestedFormFieldfor non-model nested data, and the deprecatedcreate_modelform_class. -
dev.filtering— Filtering & search:GuruFilterForm(filtermodel, key transforms, dynamicorder_by, omit-empty,execute_filter),GuruQueryParamFilterFormMixin(query-string filtering on a view viagetQueryset), andGuruFilterView(POST search endpoint). -
dev.secure— Securing API endpoints: theapi_requestdecorator auth order (conflict guard → custom callback → session → HMAC signed URL → HMAC data signature → token), theApiAccess/ApiAccessTokencredential models, and theEncryptedFieldfamily (Fernet/HKDF, lookup constraints).
Updated pages
-
dev.view-workflow— added theGuruApiRestViewworkflow (GET via details mixin; PUT/PATCH via update mixin; DELETE; POST→405), object caching (cache_object_argument_name='gobject'), the read-only-fields guard,operationCodemapping, and a "See Also" footer. -
dev.client-tools— Guru Client library (API consumption). Filled the Architecture intro tying the module layout (utils/local/remote/auth/apisettings) to the core classes andRemoteServer. Added a Model and Collection Conventions section documenting the two-endpoint contract: collection class methods (fetch/fetch_modelinstance/create, mirroring the management endpoint) vs. model instance methods (update/delete, mirroring the REST endpoint), plus thefetch_endpoint/resource_url/pk_attrproperties that drive them — noting that the base library supplies the plumbing while concrete clients supply the convention methods. Filled the Extending Guru Client TODO with a worked, source-grounded example built from the Sonador ETL client (server, model/collection base classes, a concrete resource, the parent-association pattern, reuse of thefetch_*helpers, and thefetch_*/get_*naming convention). -
dev.data-models— expanded "Next Steps" to route into the new view-workflow / forms / filtering / secure pages. -
home.md— added a "New to Guru?" callout intodev.overview+ quickstart; expanded the Libraries section with the new pages. -
_sidebar.md— reorganized into role-based groups (Start Here, Building REST-like APIs, Client Libraries, Reference & Specs, Deployment); fixed a typo. -
spec-guru-backbone-forms— added a deprecation banner pointing to the currentdev.forms/dev.view-workflowpages.
Addresses oak-tree/medical-imaging/imaging-development-env#56 (closed)
Covers the framework-side checklist items: lib/guru form-driven validation, lib/secure (credentials/tokens + api_request), the forms.py components (GuruCoreForm, RelatedModelField, ManyToManyRelatedModelField, create_modelform_class), and the filter.py components (GuruFilterForm, GuruQueryParamFilterFormMixin, GuruFilterView).
It also covers the framework side of "How are the APIs consumed?" — the Guru Client library conventions in dev.client-tools: the management-endpoint collection methods (fetch/fetch_modelinstance/create), the REST-endpoint instance methods (update/remove), and how to extend the library for a new API. The Sonador-specific consumption (the Orthanc plugin and the Sonador IO client's local/remote/sr axes) is tracked in the companion MR !9 above.
📘 Scope note: thelib/wgtauthreference named in the MR title is not yet included here — it is planned as a follow-up so the Guru/secure framework pages can land first.