Skip to main content

Smart Objects

Project description


SmartObject is a tool to easily manipulate object attributes with the API commands, store and synchronize object data.

Mapped object attributes (called properties) can be automatically validated, saved, loaded, serialized and synchronized with the external services.

SmartObject looks like ORM, but it's different from ORM: object properties can be stored in storages of different type and combined together into a single data object.

Property values are automatically processed, validated and synchronized with external services if required.

Note: all SmartObject methods are thread-safe (at least they should be :)


You have a team of people with heart-rate sensors. Data for each person is stored into local JSON files, heartbeat is stored in Redis database. How to implement this with SmartObject? Just a few lines of code:

import smartobject

class Person(smartobject.SmartObject):

    def __init__(self, name): = name

smartobject.define_storage(smartobject.RedisStorage(), 'r1')

people = smartobject.SmartObjectFactory(Person)

# create objects with factory

# create object manually
jack = Person('Jack')

people.set_prop('John', 'sex', 'male')
people.set_prop('Jane', 'sex', 'female')
people.set_prop('Jack', { 'sex', 'male' })

# add Jack to factory

print('Heartbeat of Jack is: {}'.format(people.get('Jack').heartbeat)

The file person.yml is a property map for the Person object. It can be loaded from the external YAML file or specified directly, as Python dict.

The map for the above example looks like:

    pk: true
    type: str
        - male
        - female
        - other
    store: true
    external: true
    store: r1

Pretty simple, isn't it? You define a map, SmartObject does the job!


pip3 install smartobject


Full documentation is available at

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for smartobject, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size smartobject-0.0.3.tar.gz (11.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page