rattail.datasync.rattail
¶
DataSync for Rattail
- class rattail.datasync.rattail.FromRattailToRattailBase(*args, **kwargs)[source]¶
Base class for Rattail -> Rattail datasync consumers
- get_host_object(session, change)[source]¶
You must override this, to return a host object from the given
DataSyncChange
instance. Note that the host object need not be normalized, as that will be done by the importer. (This is effectively the only part of the processing which is not handled by the importer.)
- get_importers()[source]¶
Returns a dictionary, keys of which are “model” names (e.g.
'Product'
) and values of which areImporter
instances.Note
The keys must ultimately align with the
payload_type
values, coming from the host system. Or at least that’s what will make life easy for theinvoke_importer()
method.
- class rattail.datasync.rattail.FromRattailToRattailExportConsumer(*args, **kwargs)[source]¶
Export data changes from “local” Rattail to another
- begin_transaction()[source]¶
Called just before the consumer is asked to process changes, possibly via multiple batches.
- commit_transaction()[source]¶
Called just after the consumer has successfully finished processing changes, possibly via multiple batches.
- pre_process_changes(session, changes)[source]¶
Implement any “pre-processing” logic here.
Common example would be to establish DB connection to some external system(s).
In some rare cases you may also need to “sort” the changes, to ensure they are processed in a particular sequence.
- Returns:
If you needed to modify the list of changes, you can return the new list. If this method returns
None
(which the default logic does) then the original set of changes will be processed.
- class rattail.datasync.rattail.FromRattailToRattailImportConsumer(*args, **kwargs)[source]¶
Import data changes from another Rattail to “local”
- get_host_object(session, change)[source]¶
You must override this, to return a host object from the given
DataSyncChange
instance. Note that the host object need not be normalized, as that will be done by the importer. (This is effectively the only part of the processing which is not handled by the importer.)
- class rattail.datasync.rattail.RattailConsumer(*args, **kwargs)[source]¶
DataSync consumer for Rattail databases.
- delete_instance(session, instance)[source]¶
Delete the given model instance from the given database session.
Subclasses may define model-specific methods instead of or in addition to overriding this generic one.
- get_data_model()[source]¶
Subclasses may override this if they have extended the schema. Defaults to
rattail.db.model
.
- merge_instance(session, instance)[source]¶
Merge the given model instance into the given database session.
Subclasses may define model-specific methods instead of or in addition to overriding this generic one.