Repository navigation
feat: public controller registry lookup, with one precedence rule - #173
Merged
Merged
Conversation
- register_controller_type, get_registered_controller_types and registered_controller_types mirror the type-registry API - find_controller_type maps an entity's type IRIs to a controller, optionally filtered by the interface it has to provide - lets a caller act on an entity without importing the concrete controller class
- mirrors register_type, get_registered_type and registered_types onto the v1 type registry - adds the controller counterparts and find_controller_type - the v1 models keep their own registries, so a caller has to reach the matching one
- resolve_type takes the controller registry of the model registry's layer - several controllers for one IRI: the last registered wins, instead of falling back to the pure model and disabling controller resolution - get_registered_controller_types returns last-first, like the other two accessors - register_type / register_controller_type flatten nested IRI lists and raise on an unusable IRI instead of no-op - v1 register_type gets the inherited-IRI guard the v2 path has - every registration logged at info, overrides at warning - conftest restores the controller registries, deep-copying the lists
__oold_register__ = False keeps a controller that reuses another model out of the lookup, so it stops competing for that model's type IRI. It stays constructible from the model and explicitly registerable.
A caller that has to build a connection it was not handed needs to see which credentials are available, or report the choice as ambiguous.
- resolve_type logs a multi-controller IRI at debug; the warning belongs to registration, which happens once - a reloaded module re-registers rather than piling up a second copy and reporting it as an override - an unusable IRI next to a usable one no longer breaks registration - an inline linked document resolves to the controller too, falling back to the pure model when the controller cannot be built from it - say that __oold_register__ is inherited, and report an inherited-only registration instead of silently doing nothing - tests for the v1 accessors, the v1 opt-out and re-registration
Contributor
Release previewMerging this PR would release v2.3.0 (current: Changelog preview (truncated)## v2.3.0 (2026-10-15)
### Bug Fixes
- One precedence rule for controllers, isolated per pydantic layer
([`2b3f70d`](https://github.com/OO-LD/oold-python/commit/2b3f70dc27d42a508a90ebaa4eeca1dae0fd16a2))
- Quieter registry logging, and controllers for inline documents
([`37c578e`](https://github.com/OO-LD/oold-python/commit/37c578e7b81f91075e5c6ef2ce9ed993ad0e4dda))
### Features
- Let a class opt out of the type registries
([`e501f01`](https://github.com/OO-LD/oold-python/commit/e501f0103e488d2354cd3b34a0561e1fd146c125))
- Public lookup for the controller type registry
([`e777b70`](https://github.com/OO-LD/oold-python/commit/e777b7091484f6aad4edbe3cc3e0419deccc23df))
- Public registry lookup for the pydantic v1 models
([`84b76cb`](https://github.com/OO-LD/oold-python/commit/84b76cb003e9560dc1c6c2d2262c0e363dfcc85b))
- **auth**: Expose the registered credentials
([`12e979b`](https://github.com/OO-LD/oold-python/commit/12e979b65e2acfe1a5342c0118df6ef6206108b2))
Preview via python-semantic-release and conventional commits. |
Contributor
📊 Benchmark ResultsClick to see benchmark comparisonThreshold: 1.3x (30% slower triggers a regression warning) Note: Benchmarks are informational only and won't fail the build. 💡 Tip: Download the |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the controller registry usable from outside oold, and gives resolution one
precedence rule instead of three.
Public lookup
A caller holding an entity could not find the controller that implements it
without knowing the concrete class, so downstream packages reached into
_controller_typesdirectly. Added, for both pydantic layers:register_type()/register_controller_type()get_registered_type()/get_registered_controller_types()registered_types()/registered_controller_types()find_controller_type(type_iris, base=None)oold.backend.auth.registered_credentials()One precedence rule
Previously the three accessors disagreed:
get_registered_controller_typesreturned earliest-first,
find_controller_typelast-first, andresolve_typerefused to resolve at all once a second controller was registered - which turned
the documented override mechanism into a way of disabling controllers.
from_json/from_jsonldand for inline linked documents, falling back tothe pure model when the controller cannot be built from the document.
the model registry belongs to.
resolve_typetook the v2 controller registryeven when resolving a v1 type.
Registration
__oold_register__ = Falsekeeps a class out of both registries. For acontroller that reuses another model without being its handler - an in-memory
buffer over a local-file model - which would otherwise compete for that
model's type IRI.
register_typegained the inherited-IRI guard the v2 path had: asubclass that only narrows a field reported its parent's IRI and replaced it,
so every parent document deserialized as the subclass.
register_type/register_controller_typeflatten nested IRI lists andraise on an unusable IRI instead of silently doing nothing.
importlib.reloadre-registers rather than piling up a second copy.Notes
OOLD_DESCRIPTOR_BINDING=0.tests/conftest.pynow restores the controller registries between tests,deep-copying the per-IRI lists.
opensemantic.core-python
(file controllers) and
osw-python
(
registered_credentials). Both unpin once this lands.