Skip to content

refactor: take the file controllers from opensemantic.core - #214

Open
simontaurus wants to merge 8 commits into
mainfrom
feat/file-controllers-from-core
Open

simontaurus wants to merge 8 commits into
mainfrom
feat/file-controllers-from-core

Conversation

@simontaurus

Copy link
Copy Markdown
Contributor

The file controllers moved to opensemantic.core, which owns the file models.
This package keeps the import paths and the wiki implementation.

  • base, local, memory and remote wrap the implementations in core.
  • WikiFileController rebases on core's RemoteFileController and registers
    itself, so a file entity resolves to it through get_file_controller without
    being imported by name.
  • The session is optional and built on first use. A file that is about to be
    uploaded has no URL yet, so the wiki is found from the credential registered
    in oold.backend.auth when there is no URL to go by, and the error names the
    ambiguity when several are registered.
  • Sessions are cached per (host, credential): two credentials scoped to
    different paths of one wiki are two logins, and one credential matching
    several subdomains does not serve them all the same session. A replaced
    credential replaces the session instead of being ignored for the lifetime of
    the process.
  • from_other keeps a session the source already carries.
  • LocalFileController keeps path as a field in step with the model's
    local_path, so dict()["path"] and __fields__["path"] work as before.
    Core exposes the derived path as resolve_path(): a property named like a
    model field wins over that field in attribute lookup, which is exactly what
    FileResult.path runs into.

tests/test_wiki_file_session.py covers how the session is found and cached.

Needs the file controllers from opensemantic.core, merged but not yet released,
so that dependency is pinned to its main until a version tag is cut.

- base, local, memory and remote now wrap the implementations that moved
  to core, which owns the file models
- LocalFileController keeps the path argument and filename-derived label
- WikiFileController rebases on core's RemoteFileController
- the session became optional and connects on first use from the
  credential registered for download_url or access_url
- the package imports its modules, so the controllers register and a file
  entity resolves to one without importing it by name
- _ensure_session falls back to the registered credential, so an upload
  (which has no URL yet) can use the lazy session at all
- from_other keeps a session the source carries instead of writing None
- sessions are cached per credential, not per host, and a replaced
  credential replaces the session
- LocalFileController without a file fails at construction, as the
  controller it replaces did
- pin opensemantic.core to the branch carrying the file controllers
- a credential registered as host/path no longer becomes the WtSite iri,
  which built an API endpoint that does not exist
- the cache is keyed by (host, credential), so one credential matching
  several subdomains does not serve them all the same session
- pin oold to the branch carrying registered_credentials()
- tests inspect the config the session is built from
Core renamed its path property to resolve_path(), because a property
named like a model field wins over the field and makes its value
unreadable - osw.express.FileResult declares exactly such a field. With
path declared here instead, dict()["path"] and __fields__["path"]
work again and the two names always name the same file.
@github-actions

Copy link
Copy Markdown
Contributor

Release preview

No version bump from the current commits (stays at v2.8.1). Use conventional commit types (feat, fix, ...) to trigger a release.

Changelog preview (truncated)

Preview via python-semantic-release and conventional commits.

Every characteristic branches off the Characteristic category, and the
schema marks the link required - which oold enforces since the
descriptor binding.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant