Package s3 :: Module s3sync :: Class S3SyncBaseAdapter
[frames] | no frames]

Class S3SyncBaseAdapter

source code

object --+
         |
        S3SyncBaseAdapter

Sync Adapter (base class) - interface providing standard synchronization methods for the respective repository type.

This class isn't meant to be instantiated or accessed directly, but is normally accessed through the S3SyncRepository instance.

Instance Methods
 
__init__(self, repository)
Constructor
source code
 
register(self)
Register this site at the peer repository
source code
 
login(self)
Login at the peer repository
source code
 
pull(self, task, onconflict=None)
Fetch updates from the peer repository and import them into the local database (active pull)
source code
 
push(self, task)
Extract new updates from the local database and send them to the peer repository (active push)
source code
 
send(self, resource, start=None, limit=None, msince=None, filters=None, mixed=False, pretty_print=False)
Respond to an incoming pull from the peer repository
source code
 
receive(self, source, resource, strategy=None, update_policy=None, conflict_policy=None, onconflict=None, last_sync=None, mixed=False)
Respond to an incoming push from the peer repository
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, repository)
(Constructor)

source code 

Constructor

Parameters:
  • repository - the repository (S3Repository instance)
Overrides: object.__init__

register(self)

source code 

Register this site at the peer repository

Returns:
True|False to indicate success|failure, or None if registration is not required

login(self)

source code 

Login at the peer repository

Returns:
None if successful, otherwise the error

pull(self, task, onconflict=None)

source code 

Fetch updates from the peer repository and import them into the local database (active pull)

Parameters:
  • task - the synchronization task (sync_task Row)
  • onconflict - callback for automatic conflict resolution
Returns:
tuple (error, mtime), with error=None if successful, else error=message, and mtime=modification timestamp of the youngest record sent

push(self, task)

source code 

Extract new updates from the local database and send them to the peer repository (active push)

Parameters:
  • task - the synchronization task (sync_task Row)
Returns:
tuple (error, mtime), with error=None if successful, else error=message, and mtime=modification timestamp of the youngest record sent

send(self, resource, start=None, limit=None, msince=None, filters=None, mixed=False, pretty_print=False)

source code 

Respond to an incoming pull from the peer repository

Parameters:
  • resource - the resource to be synchronized
  • start - index of the first record to send
  • limit - maximum number of records to send
  • msince - minimum modification date/time for records to send
  • filters - URL filters for record extraction
  • mixed - negotiate resource with peer (disregard resource)
  • pretty_print - make the output human-readable
Returns:
a dict {status, remote, message, response}, with:
  • status....the outcome of the operation
  • remote....whether the error was remote (or local)
  • message...the log message
  • response..the response to send to the peer

receive(self, source, resource, strategy=None, update_policy=None, conflict_policy=None, onconflict=None, last_sync=None, mixed=False)

source code 

Respond to an incoming push from the peer repository

Parameters:
  • source - the input stream (list of file-like objects)
  • resource - the target resource
  • strategy - the import strategy
  • update_policy - the update policy
  • conflict_policy - the conflict resolution policy
  • onconflict - callback for conflict resolution
  • last_sync - the last synchronization date/time for the peer
  • mixed - negotiate resource with peer (disregard resource)
Returns:
a dict {status, remote, message, response}, with:
  • status....the outcome of the operation
  • remote....whether the error was remote (or local)
  • message...the log message
  • response..the response to send to the peer