rattail.db.changes¶
Data Changes Interface
- class rattail.db.changes.ChangeRecorder(config)[source]¶
Listener for session
before_flushevents.This class is responsible for adding stub records to the
changestable, which will in turn be used by the database synchronizer to manage change data propagation.- ensure_uuid(instance)[source]¶
Ensure the given instance has a UUID value.
This uses the following logic:
If the instance already has a UUID, nothing will be done.
If the instance contains a foreign key to another table, then that relationship will be traversed and the foreign object’s UUID will be used to populate that of the instance.
Otherwise, a new UUID will be generated for the instance.
- process_deleted_object(session, obj)[source]¶
Record changes as appropriate, for the given ‘deleted’ object.
- process_dirty_object(session, obj)[source]¶
Record changes as appropriate, for the given ‘dirty’ object.
- process_new_object(session, obj)[source]¶
Record changes as appropriate, for the given ‘new’ object.
- record_change(session, quiet=False, **kwargs)[source]¶
Record a change, by creating a new change record in the session.
- record_rattail_change(session, instance, type_='dirty')[source]¶
Record a change record in the database.
If
instancerepresents a change in which we are interested, then this method will create (or update) arattail.db.model.Changerecord.- Returns:
Trueif a change was recorded, orFalseif it was ignored.
- rattail.db.changes.record_changes(session, recorder=None, config=None)[source]¶
Turn on the “record changes” feature.
With this enabled, all relevant data changes which occur in the sesion will be recorded.
- Parameters:
session¶ – A
sqlalchemy.orm.session.Sessionclass, or instance thereof.