|Version 2 (modified by 12 years ago) ( diff ),|
S3XRC | Data Synchronization
S3XRC - Data Synchronisation
msince parameter allows selecting of records since a specific time. This needs to be ISO8601, i.e.
If given, this exports only resources which have been modified since this date/time (=if either the main record or any of its component records has been modified since then). Referenced resources are exported regardless of "msince", because it could always be that the reference itself has changed since then.
vector.strategy contains the allowed import strategies as a list, which allows you to control the import behavior:
If this list is empty (or None), then the importer skips this records (and all related components).
If this list contains vector.METHOD.CREATE, then new records will be created, otherwise records from the import source which don't have an instance in the local database, will be skipped (together will all their components).
If this list contains vector.METHOD.UPDATE, then vectors which already have a local instance will be updated from the import source, otherwise they will be ignored (together will all their components).
The function hooked in as s3xrc.sync_resolve(vector) is expected to set vector.strategy according to the policies, otherwise the fallback strategy will allow both, create and update.
The function s3xrc.sync_resolve(vector) can issue a resolution per vector, that is, you can tell the importer which fields from which record (the local one or the imported one) are to be kept for the import:
vector.resolution can contain this resolution either as a single value, or as a dict of values with fieldnames as keys (per-field resolution). There are three possible values for resolution:
vector.RESOLUTION.THIS means: keep the local value vector.RESOLUTION.OTHER means: keep the imported value (if any) vector.RESOLUTION.NEWER means: keep the newer value
vector.resolution falls back to vector.default_resolution.
If you use per-field resolutions, you need to set vector.default_resolution for all fields for which there is no entry in vector.resolution. The default resolution falls back to vector.RESOLUTION.THIS.