There are two methods to follow changes to certain server contents. The first, ICS (incremental change synchronization) allows for state-based synchronization. The other, notifications, provides real-time updates whenever something changes.
Based on a given state, ICS exports all subsequent changes and when there are no more changes, returns the new state. Changes are communicated to a call-back object, with the following (optional) methods:
class Importer: def update(self, obj, flags=None): print('new or updated:', obj, flags) def delete(self, obj, flags=None): print('deleted:', obj, flags) def read(self, obj, status): # items only print('read state change:', obj, status)
Using this, we can synchronize the items of a specific folder:
Or even all item changes for an entire Kopano server (system-wide ICS):
In the folder case, we can omit the state, in which case the entire folder is synchronized.
We can also synchronize the sub-folder hierarchy for a given folder (usually subtree):
Finally, we can also synchronize the addressbook as follows:
Note that on deletion, the actual object is gone when the call-back happens. For items and folders only obj.sourcekey remains, and for users only obj.userid.
Note also that old changes are not kept in the system, so intermediate changes are never exported.
Notifications provide real-time tracking of specific classes of changes. Similar to ICS, a call-back object receives the changes:
class Sink: def update(self, notification): print('changed:', notification.object, notification.object_type, notification.event_type)
Now, to subscribe to all changes to a specific folder:
To only receive changes to the folder items themselves, specify object type (folder or item):
To only receive certain event types for these items (created, updated, deleted):
folder.subscribe(Sink(), object_types=['item'], event_types=['created', 'deleted'])
To subscribe to all changes to a given store:
To only receive changes to folders, specify object type (folder or item):