autowisp.browser_interface.diagnostics.forms module

Class Inheritance Diagram

Inheritance diagram of DiagnosticExpressionForm

The form behind the diagnostic expression management page.

The library lives in the project database rather than in a Django model, so this is a plain Form: Django still does the per-field checks and error plumbing, while the one check a model used to supply – that the name is not already taken – is made here against the library.

What Django cannot know is whether the expression means anything. That is check_expression(), which returns its complaints as plain strings rather than raising so that it stays usable with no Django at all. Turning those strings into ValidationErrors is this module’s whole reason to exist, and the only place that adaptation happens.

class autowisp.browser_interface.diagnostics.forms.DiagnosticExpressionForm(*args, expressions=None, replacing=None, **kwargs)[source]

Bases: Form

Inheritance diagram of autowisp.browser_interface.diagnostics.forms.DiagnosticExpressionForm

Validate one proposed expression against the library it would join.

Validity does not depend on what the project has recorded – see autowisp.diagnostics.diagnostic_types – so only the library is consulted; whether the diagnostics an expression needs exist is a separate question, answered by counting rows elsewhere.

__init__(*args, expressions=None, replacing=None, **kwargs)[source]
Parameters:
  • expressions (dict) – The library, {name: expression}, this one would join. The view has it and the form does not, so it arrives as a keyword argument.

  • replacing (str or None) – The name of the stored expression being edited, or None when adding. An entry of that name is treated as the one being replaced rather than as a conflict, so an edit can pass the library unchanged.

base_fields = {'description': <django.forms.fields.CharField object>, 'expression': <django.forms.fields.CharField object>, 'name': <django.forms.fields.SlugField object>}
clean()[source]

Report what check_expression says, against the field at fault.

declared_fields = {'description': <django.forms.fields.CharField object>, 'expression': <django.forms.fields.CharField object>, 'name': <django.forms.fields.SlugField object>}
property media

Return all media required to render the widgets on this form.