Core Object Model
Project description
object-model
Table of Contents
[WORK IN PROGRESS]
Overview
For creating a data model in python, dataclasses and pydantic model-based classes
provide a solid foundation. However, they lack important features, mostly related to persistence.
object-model provides these enhancements.
Pydantic and dataclasses
Pydantic and dataclasses both provide ways to define data objects. dataclasses are attractive in that they are part of the standard python library. Pydantic provides useful extra functionality such as:
- converting types to JSON Schema
- serialisation to/from json
- validation of inputs when constructing objects
the above features can (mostly) also be used with dataclasses. object-model provides
a simple API for handling both styles.
Input validation only truly works on pydantic objects but all else works on both.
Serialising Subclasses
The Base and BaseModel types automatically add the object's name to the serialised output.
The name can be overridden to avoid collisions. Type names are registered in the project's
entry points under the group object-store. This serves as a registry of types and allows
the implementation to be moved without needing to load and re-write persisted objects.
Pydantic's json serialisation does not natively provide a mechanism to serialise a member whose
type is a subclass of the specified type. object-model provides a Subclass type, which expands
to a discriminated union, with this type field as the discriminator.
This is represented in JSON Schema as a OneOf and allows such subclasses to be validated
against the schema.
Persistence
Data model objects need to be persistable. object-model provides:
- a bi-temporal schema with JSON/JSONB-based serialisation of the objects
- partitioning of objects by type (where the DB supports it), allowing each type to be indexed appropriately
- a simple mechanism for defining object IDs
- SQL and REST implementations of an object store
ID
Id is a descriptor field applied as a ClassVar. At class-level it specifies the
fields (or properties) which form a unique Id (when combined with the type). When called
on an object instance, it returns a tuple of the values of those fields - the object's
persisted Id. In the simplest case, object can just be a field called name.
Hierarchies of objects share the same Id. Thus, if you have a base class, the subclasses may not override the Id.
Project details
Release history Release notifications | RSS feed
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 py_object_model-1.0.0.tar.gz.
File metadata
- Download URL: py_object_model-1.0.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7eb3a0989bade24c96d577aa4eab2ac6233e24c0397dcb005c66feec32bbeb4d
|
|
| MD5 |
4d06a035b358deb08211e310b77fee58
|
|
| BLAKE2b-256 |
913c3436d5efb3087ef146761abab14dbb3ff19700011f42a5af1aa7531ab752
|
Provenance
The following attestation bundles were made for py_object_model-1.0.0.tar.gz:
Publisher:
python-publish.yml on nickyoung-github/object-model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_object_model-1.0.0.tar.gz -
Subject digest:
7eb3a0989bade24c96d577aa4eab2ac6233e24c0397dcb005c66feec32bbeb4d - Sigstore transparency entry: 160228885
- Sigstore integration time:
-
Permalink:
nickyoung-github/object-model@fba3c9e50d0696254ae6b958e1067df3d498e6b6 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/nickyoung-github
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@fba3c9e50d0696254ae6b958e1067df3d498e6b6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_object_model-1.0.0-py3-none-any.whl.
File metadata
- Download URL: py_object_model-1.0.0-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
265939a39638ad62b4f5025701dcdb4fb99958a2b9bf4808986156053ea32682
|
|
| MD5 |
2761307e98e33e077165ecf2cc38b5f8
|
|
| BLAKE2b-256 |
69f30f8c9d53b7a29d5b145f575c3a8540630964288aaf70ebc8a8b8b252393c
|
Provenance
The following attestation bundles were made for py_object_model-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on nickyoung-github/object-model
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_object_model-1.0.0-py3-none-any.whl -
Subject digest:
265939a39638ad62b4f5025701dcdb4fb99958a2b9bf4808986156053ea32682 - Sigstore transparency entry: 160228887
- Sigstore integration time:
-
Permalink:
nickyoung-github/object-model@fba3c9e50d0696254ae6b958e1067df3d498e6b6 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/nickyoung-github
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@fba3c9e50d0696254ae6b958e1067df3d498e6b6 -
Trigger Event:
release
-
Statement type: