Synchronization

When SmartObject properties are changed with set_prop() method, synchronization is called instantly (if the property is mapped).

SmartObject package has no ready-made classes to implement object synchronization.

class smartobject.sync.AbstractSync

Abstract synchronizer class which can be used as synchronizer template

delete(pk, **kwargs)

Delete object data

The method is called when the object is deleted

Parameters:pk – object primary key
sync(pk, data={}, **kwargs)

Sync object data

The method is called every time object requests to be synchronized

Parameters:
  • pk – object primary key
  • data – object data to sync
class smartobject.sync.DummySync

Dummy synchronizer class with empty methods

Does nothing, useful for testing

smartobject.sync.define_sync(sync, id=None)

Define new synchronizer

The synchonizer must implement methods of AbstractSync class

Parameters:
  • sync – synchronizer object
  • id – sync id, if not specified, default sync is defined
smartobject.sync.get_sync(id=None)

Get synchronizer

Parameters:id – sync id, if not specified, default sync is returned