# datastore.objects
[datastore.objects](https://github.com/datastore/datastore.objects) is a simple object mapper on top of [datastore](https://github.com/jbenet/datastore) (not relational). Thanks to datastore’s versatility, it makes it easy to (serialize and) persist custom classes to any sort of data storage service.
Notice: please familiarize yourself with datastore first.
## Install
pip install datastore.objects
## Interface
### Key
datastore.objects uses the default datastore.Key, making significant use of the type and instance fragments.
`python >>> from datastore.objects import Key, Model >>> class Scientist(Model): >>> pass >>> Scientist.key Key('/Scientist') >>> Scientist('Tesla').key Key('/Scientist:Tesla') `
### Model
datastore.objects provides a class that you inherit from to define your models. datastore.objects.Model handles the datastore serializing and deserializing, attribute validation, etc.
`python >>> from datastore.objects import Model >>> class Scientist(Model): >>> pass `
### Attribute
datastore.objects uses descriptor Attributes to track the properties you wish to store. This is heavily based on how other python ORMs (django, app engine) do it. In short, you define model attributes like this:
`python >>> from datastore.objects import Attribute, Model >>> class Scientist(Model): >>> name = Attribute(required=True) >>> field = Attribute(default='Physics') >>> tesla = Scientist('Tesla') >>> tesla.name = 'Nicola Tesla' >>> tesla.field 'Physics' >>> tesla.field = 'Electrical Engineering' >>> tesla.data {'name': 'Nicola Tesla', 'field': 'Electrical Engineering'} `
### ObjectDatastore
datastore.objects provides a ShimDatastore that wraps any other datastore. Thus you can use any of the various datastores to persist your objects. ObjectDatastore makes sure to serialize (on put) and deserialize (on get) data properly, and construct your classes.
`python >>> import datastore >>> from datastore.objects import Attribute, Model, ObjectDatastore >>> >>> class Scientist(Model): >>> name = Attribute(required=True) >>> field = Attribute(default='Physics') >>> >>> tesla = Scientist('Tesla') >>> tesla.name = 'Tesla' >>> tesla.field = 'Electrical Engineering' >>> >>> dds = datastore.DictDatastore() >>> ods = ObjectDatastore(dds, model=Scientist) >>> ods.put(tesla.key, tesla) >>> dds.get(tesla.key) {'name': 'Tesla', 'field': 'Electrical Engineering'} >>> ods.get(tesla.key) <Model /Scientist:Tesla> `
## About
#### Author
datastore.objects is written by [Juan Batiz-Benet](https://github.com/jbenet), of [Athena](http://athena.ai).
#### License
It is free open-source software, available under the MIT License.
#### Contact
Project webpage: https://github.com/datastore/datastore.objects. Issues: https://github.com/jbenet/object-datastore/issues
Metadata
Release files for datastore.objects 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datastore.objects-0.2.3.tar.gz | 35.9 kB | Without provenance | Details for datastore.objects-0.2.3.tar.gz |
Release files / datastore.objects-0.2.3.tar.gz
| Download URL | datastore.objects-0.2.3.tar.gz |
|---|---|
| Size | 35.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf243ab33d1355a52fdcbd4b6b703b4b6a942e9551947b46b3d44c3b58081ff6
|
|
BLAKE2b-256 checksum How to use checksums |
e97099c8a01be203d05b4d8d34c827a2eb0d2e4cfce0eed4b62d77687ce8029a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for datastore.objects 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.