wuttaweb.diffs

Tools for displaying simple data diffs

class wuttaweb.diffs.MergeDiff(config, removing_data, keeping_data, final_data, **kwargs)[source]

Special diff class for use when merging 2 records. While based on WebDiff, this class uses a different signature for the constructor.

It shows the “removing” record, the “keeping” record, and also the “final” record showing the calculated result of the merge, with special highlighting where values would change on the kept record.

Parameters:
  • config – The app config object.

  • removing_data – Dict of data for the “removing” record.

  • new_data – Dict of data for the “keeping” record.

  • new_data – Dict of “final” data for the kept record.

  • **kwargs – Remaining kwargs are passed as-is to the WebDiff constructor.

class wuttaweb.diffs.VersionDiff(config, version, **kwargs)[source]

Special diff class for use with version history views. While based on WebDiff, this class uses a different signature for the constructor.

Parameters:
  • config – The app config object.

  • version – Reference to a Continuum version record object.

  • **kwargs – Remaining kwargs are passed as-is to the WebDiff constructor.

render_version_value(version, field, value)[source]

Render the cell value HTML for a given version + field.

This method is used to render both sides of the diff (old + new values). It will just render the field value using a monospace font by default. However:

If the field is involved in a mapper relationship (i.e. it is the “foreign key” to a related table), the logic here will also (try to) traverse that show display text for the related object (if found).

Parameters:
  • version – Reference to the Continuum version object.

  • field – Name of the field, as string.

  • value – Raw value for the field, as obtained from the version object.

Returns:

Rendered cell value as HTML literal

class wuttaweb.diffs.WebDiff(config, old_data: dict, new_data: dict, fields: list = None, nature='update', old_color='#ffebe9', new_color='#dafbe1', cell_padding=None)[source]

Simple diff class for the web app.

This is based on the Diff class; it just tweaks render_html() to use the web template lookup engine.

cell_padding = None
render_html(template='/diff.mako', **kwargs)[source]

Render the diff as HTML table.

Parameters:
  • template – Name of template to render, if you need to override the default.

  • **kwargs – Remaining kwargs are passed as context to the template renderer.

Returns:

HTML literal string