Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.core.diff

Functions

state2dict(obj)

Classes

ChangeWatcher(watched)

Lightweight volatile object to watch changes on a database object.

class lino.core.diff.ChangeWatcher(watched)

Bases: object

Lightweight volatile object to watch changes on a database object.

This is used e.g. by the on_ui_updated signal.

watched

The model instance which has been changed and caused the signal.

original_state

a dict containing (fieldname –> value) before the change.

get_updates(ignored_fields=frozenset({}), watched_fields=None)

Yield a list of (fieldname, oldvalue, newvalue) tuples for each modified field. Optional argument ignored_fields can be a set of fieldnames to be ignored.

get_updates_html(*args, **kwargs)

A more descriptive variant of get_updates() which uses a more intuitive description of the changes:

  • a unified diff for text fields.

get_old_value(fieldname)

Return the old value of the specified field.

has_changed(fieldname)

Return True if the specified field has changed.

is_dirty()

Return True if any watched field has changed.