wtform_fields module - Platform - BlueCat Gateway - 24.1

Gateway Administration Guide

Locale
English
Product name
BlueCat Gateway
Version
24.1

Custom WTForm fields. This is where all the UI Components Fields and their base classes are located.

Click a link to jump to the indicated section.

class bluecat.wtform_fields.AliasRecord(*args, **kwargs)

Bases: bluecat.wtform_fields.validating_string_field.ValidatingStringField

StringField for inputting Alias Records with client side validation and auto-checks that it is available.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

result_decorator

Function to manipulate result set instead of a server-side call.

kwargs

Other keyword arguments for WTForms Fields.

class bluecat.wtform_fields.Configuration(*args, **kwargs)

Bases: bluecat.wtform_fields.custom_select_field.CustomSelectField

SelectField that is auto-populated with configuration data.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

kwargs

Other keyword arguments for WTForms Fields.

widget = <bluecat.ui_components.wtform_widgets.SuperSelect object>

class bluecat.wtform_fields.CustomBooleanField(*args, **kwargs)

Bases: wtforms.fields.simple.BooleanField bluecat.wtform_fields.extended_field.ExtendedField

Custom boolean/checkbox class that extends WTForms to generate html and JavaScript checkbox code.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

on_checked

JavaScript functions to call when checkbox is checked.

on_unchecked

JavaScript functions to call when checkbox is unchecked.

kwargs

Other keyword arguments for ExtendedField and WTForms Field.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_checkbox_javascript()

Generates JavaScript to handle the checking/un-checking and populating of the checkbox.

Returns: JavaScript code to handle changes to checkbox.

generate_event_listener_js()

Generate JavaScript to call side_effect function on change.

Returns: JavaScript to call side effect function on change.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

widget = <bluecat.ui_components.wtform_widgets.SuperCheckboxInput object>

class bluecat.wtform_fields.CustomButtonField(*args, **kwargs)

Bases: wtforms.fields.simple.BooleanField bluecat.wtform_fields.extended_field.ExtendedField

A simple button object with no extra JavaScript.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

kwargs

Other keyword arguments for WTForms Fields.

widget = <bluecat.ui_components.wtform_widgets.SuperInput object>

class bluecat.wtform_fields.CustomPasswordField(*args, **kwargs)

Bases: bluecat.wtform_fields.custom_string_field.CustomStringField bluecat.wtform_fields.extended_field.ExtendedField

Password field which will fetch the value of another field as put it as it’s own when the call_{id} function is called.

Parameters Description
label

HTML label for the generated field.

inputs

Determines where to fetch the data from or what to pass to a server call. If no server_side_method is defined, then inputs must contain the id of itself mapping it to the field where to get the data from.

server_side_method

Server-side call to retrieve data.

widget = <bluecat.ui_components.wtform_widgets.SuperPasswordInput object>

class bluecat.wtform_fields.CustomSearchButtonField(*args, **kwargs)

Bases: bluecat.wtform_fields.custom_button_field.CustomButtonField

Button implementing a remote query from input data of a single field.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

clear_below_on_change

Whether to clear all fields below it when the user selects a different option.

message_field

Deprecated. Use display_message from ExtendedField instead.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_clear_below_js()

Add disable all below code.

Returns: JavaScript for CustomSearchButtonField.

generate_event_listener_js()

Generate JavaScript to call side_effect function on change.

Returns: JavaScript to call side effect function on change.

generate_populate_function_js()

Generate JavaScript for populate function. Generate empty populate function in case another js function tries to call the searchButtons populate function.

Returns: JavaScript for populate function.

generate_side_effect_function_js()

Generate JavaScript for side effect function.

Returns: JavaScript for side_effect function.

class bluecat.wtform_fields.CustomSelectField(*args, **kwargs)

Bases: wtforms.fields.choices.SelectField bluecat.wtform_fields.extended_field.ExtendedField

SelectField that is auto-populated with configuration data.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

choices_function

Python function for retrieving the choices used to populate the select field.

default_not_selected

The default value for the SelectField when nothing is selected.

clear_below_on_change

Whether to clear all fields below it when the user selects a different option.

kwargs

Other keyword arguments for WTForms Fields.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_clear_below_js()

Add disable all below code.

Returns: JavaScript

generate_event_listener_js()

Generate JavaScript to call side_effect function on change.

Returns: JavaScript to call side effect function on change.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

generate_side_effect_function_js()

Generate JavaScript for side effect function.

Returns: JavaScript for side_effect function.

widget = <bluecat.ui_components.wtform_widgets.SuperSelect object>

class bluecat.wtform_fields.CustomStringField(*args, **kwargs)

Bases: wtforms.fields.simple.StringField bluecat.wtform_fields.extended_field.ExtendedField

String field which will fetch the value of another field as put it as it’s own when the call_{id} function is called.

Parameters Description
label

HTML label for the generated field.

inputs

Determines where to fetch the data from or what to pass to a server call. If no server_side_method is defined, then inputs must contain the id of itself mapping it to the field where to get the data from.

server_side_method

Server-side call to retrieve data.

generate_call_function_js()

Generate the call function

Returns: JavaScript for call function.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

widget = <bluecat.ui_components.wtform_widgets.SuperTextInput object>

class bluecat.wtform_fields.CustomSubmitField(*args, **kwargs)

Bases: wtforms.fields.simple.SubmitField bluecat.wtform_fields.extended_field.ExtendedField

Field to render submit button

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

kwargs

Other keyword arguments for WTForms Fields.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

widget = <bluecat.ui_components.wtform_widgets.SuperSubmit object>

class bluecat.wtform_fields.ExtendedField(*args, **kwargs)

Bases: wtforms.fields.core.Field

Base class for UI Component Fields that adds extra functionality.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

inputs

Specific inputs to the server_side_method. Should be a dictionary of key and element id pairs.

enable_on_complete

Fields to enable once user is done with a field and should then move on to other fields.

on_complete

JavaScript functions to call once the user is done with a field and should move on to other fields.

on_change

JavaScript functions to call when the user changes the value of a field.

on_validate

JavaScript functions to call when the user on validation of field.

on_click

JavaScript functions to call when the user on click of field.

classes

Extra HTML classes to append to the element.

required

Whether the field must be filled in or not. If True, users must put something in the field in order to submit the form.

is_disabled_on_error

Whether the field should be disabled if the form is reloaded when an error occurs. Default: False.

is_disabled_on_start

Whether the field should be disabled if the form is first loaded. Default: True. Note: when using GatewayForm, all fields are disabled on start by default. This parameter should be True for at least one field to get the started.

server_outputs

Mapping of returned data properties to which field they should go to.

server_side_method

The server-side endpoint method the field uses to get the data it displays.

result_decorator

Function to manipulate result set instead of a server-side call.

server_side_output_method

The server-side endpoint method the field uses to populate other fields. Must be used in conjunction with server_outputs.

output_result_decorator

Function to manipulate result set instead of an output server-side call.

workflow_name

Name of the workflow the element is used in.

permissions

Which workflow permissions the server_side_method should have.

readonly

If True, the field will only be readable but not interactive. False by default.

enable_dependencies

List of dependents from which the enable_disable_dependents_generator function generates a JavaScript function to enable those dependents.

disable_dependencies

List of dependents from which the disable_dependents_generator function generates a JavaScript function to disable those dependents. The JavaScript function can then be triggered by being called in on_change, on_validate, or on_complete.

should_cascade_disable_on_change

clear_dependencies

Which workflow permissions the server_side_method should have.

should_cascade_clear_on_change

display_message

Flag on whether to display server endpoint messages.

kwargs

Other keyword arguments for WTForms Fields.

clear_component_message()

Create JS to clear a message for a ui component.

Returns: JS code

clear_dependents_generator(dependents, trigger)

Generates JavaScript function for clearing a field’s dependent fields.

Parameters Description
dependents

List of ids of the field’s dependents.

trigger

Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.

Returns: JavaScript function code as Python string.

clear_self_and_dependants_generator(has_dependents=False, trigger='on_change', cascade=False)

Generates JavaScript function for clearing a field and calling the generated function for clearing its dependent fields.

Parameters Description
has_dependents

Whether the field has dependents to be cleared along with it.

trigger

Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.

cascade

Whether the field’s dependents should be cleared along with it. Will clear dependents if True.

Returns: JavaScript function code as Python string.

enable_disable_dependents_generator(dependents, trigger, should_disable=True)

Generates JavaScript function for enabling or disabling a field’s dependent fields.

Parameters Description
dependents

List of ids of the field’s dependents.

trigger

Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.

should_disable

Whether the dependents should be enabled or disabled.

Returns: JavaScript function code as Python string.

enable_disable_self_and_dependants_generator(has_dependents=False, trigger='on_change', should_disable=True, cascade=False)

Generates JavaScript function for enabling or disabling a field and calling the generated function for disabling its dependent fields.

Parameters Description
has_dependents

Whether the field has dependents to be disabled along with it.

trigger

Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.

should_disable

Whether the dependents should be enabled or disabled.

cascade

Whether the field’s dependents should be disabled along with it. Disables dependents if True.

Returns: JavaScript function code as Python string.

classmethod fill_in_missing_triggers(trigger_dict)

Check the trigger_dict to see if it is missing any of the triggers defined for the class.

Parameters Description
trigger_dict

A dictionary containing the triggers to be checked.

Returns: The given trigger_dict with missing triggers added as keys in the dictionary with an empty list as the value.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_common_clear_code()

Generator used to generate field clearing code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_disable_code()

Generator used to generate field disabling code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_display_message_code()

Generator used to generate display message code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_enable_code()

Generator used to generate field enabling code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_common_server_output_code()

Generator used to generate server output code, should be used by child classes that inherit it to generate complete JavaScript for fields.

Returns: Generated JavaScript for the field.

generate_event_listener_js()

Generate JavaScript to listen and execute code on events.

Returns: JavaScript for event listening.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

javascript_generator()

Generates default JavaScript standard for every field.

Returns: Generated JavaScript for the field.

populate_component_message()

Create JS to populate a message for a ui component.

Returns: JS code

populate_fields_generator(outputs, trigger='on_complete')

Function for populating multiple fields from a mapping of given data to fields.

Parameters Description
outputs

Mapping of data properties to which field they should go to.

trigger

Type of event needed to occur on the field to trigger the function. For example, on_change, on_complete.

Returns: JavaScript function output_<element_id> that handles the populating of multiple fields.

post_call_generator(output_functions=None)

Generates JavaScript function that makes a one-off POST call to an endpoint generated from the workflow_name and element_io with the given inputs. On successfully callback, will call a function with name “populate_<element_id>” with the returned results.

Parameters Description
output_functions

List of functions to call with data returned from POST call.

Returns: JavaScript function code as Python string.

server_output_javascript(outputs=None, trigger='on_complete')

JavaScript function for a specific field that can be called to populate an arbitrary number of other fields based on server output from the specified endpoint.

Parameters Description
outputs

Mapping of returned data properties to which field they should go to.

trigger

The trigger for when the function should be called.

Returns: JavaScript function code as Python string.

triggers = ['on_change', 'on_validate', 'on_complete', 'on_checked', 'on_unchecked']

class bluecat.wtform_fields.FilteredSelectField(*args, **kwargs)

Bases: bluecat.wtform_fields.filtered_select_field.NoPreValidationSelectField bluecat.wtform_fields.extended_field.ExtendedField

FilteredSelectField a select field with an attached filter field that can provide hints by which to filter the results in the search field by. Provides functionality for pass-through fields as well

Parameters Description
filter_field

The field from which to get the hint string to use as a filter in the select list

message_field

Deprecated. Use display_message from ExtendedField instead.

clear_fields

The fields to clear when a new filter hint is typed

label

HTML label for the generated field.

kwargs

Other keyword arguments for WTForms Fields.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function

generate_event_listener_js()

Generate JavaScript to call other js functions on change event.

Returns: JavaScript to call functions on change event.

generate_filter_field_js()

Generate JavaScript to filter the field.

Returns: JavaScript for filtering the field.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function

widget = <bluecat.ui_components.wtform_widgets.SuperSelect object>

class bluecat.wtform_fields.HostRecord(*args, **kwargs)

Bases: bluecat.wtform_fields.validating_string_field.ValidatingStringField

StringField for inputting the host records

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

result_decorator

Function to manipulate result set instead of a server-side call.

kwargs

Other keyword arguments for WTForms Fields.

class bluecat.wtform_fields.IP4Address(*args, **kwargs)

Bases: bluecat.wtform_fields.validating_string_field.ValidatingStringField

StringField for inputting IPv4 addresses with client-side validation and auto-checks that it is available.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

result_decorator

Function to manipulate result set instead of a server-side call.

kwargs

Other keyword arguments for WTForms Fields.

class bluecat.wtform_fields.NoPreValidationSelectField(*args, **kwargs)

Bases: wtforms.fields.choices.SelectField

SelectField with no pre-validation of field value against possible choices. Useful if choices are dynamically populated.

pre_validate(form)

Pre-validate method being overwritten to no longer perform validation.

Parameters Description
form

The form the field belongs to.

class bluecat.wtform_fields.PlainHTML(*args, **kwargs)

Bases: wtforms.fields.core.Field

Field to render plain HTML

Parameters Description
text

HTML text.

kwargs

Other keyword arguments for WTForms Fields.

widget = <bluecat.ui_components.wtform_widgets.HTMLWidget object>

class bluecat.wtform_fields.SimpleAutocompleteField(*args, **kwargs)

Bases: wtforms.fields.simple.StringField bluecat.wtform_fields.extended_field.ExtendedField

Generic auto-complete enabled Field.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

one_off

Whether the data from the server_side_method is only retrieved once or every time the input changes.

source

A static list from which auto-complete should filter and display based on user input. Used instead of server_side_method.

clear_below_on_change

Whether to clear all fields below it when the user selects a different option.

kwargs

Other keyword arguments for WTForms Fields.

generate_call_function_js()

Override default JS for call function

Returns: JavaScript function snippet.

generate_clear_below_js()

Add disable all below code.

Returns: JavaScript for CustomSearchButtonField.

generate_populate_function_js()

Override default JS for populate function

Returns: JavaScript function snippet.

widget = <bluecat.ui_components.wtform_widgets.SuperTextInput object>

class bluecat.wtform_fields.TableField(*args, **kwargs)

Bases: bluecat.wtform_fields.extended_field.ExtendedField

Field to render Table data

Parameters Description
label

HTML label for the generated field.

data_function

Function to pre-populate the table with data

table_features

Dictionary containing feature terms to enable in the table, more info: https://datatables.net/reference/option/

buttons

A list containing the names of buttons to enable. Default: [‘export’] Valid elements: ‘import’, ‘export’

server_side_method

The server-side endpoint method the field uses to get the data it displays.

inputs

Specific inputs to the server_side_method. Should be a dictionary of key and element id pairs.

workflow_name

Name of the workflow the element is used in.

permissions

Which workflow permissions the server_side_method should have.

generate_call_function_js()

Generate JavaScript for call function.

Returns: JavaScript for call function.

generate_common_clear_code()

Override the default clear code generation with Table specific logic

Returns: JavaScript for common clear JS code.

generate_default_features()

Generate default DataTable features.

Returns: Javascript code for the default DataTable features.

generate_global_scope_js()

Generate the JavaScript code for the component, to be placed in the global scope.

Returns: JavaScript code for the global scope.

Return type: str

generate_parse_data_function_js()

Parse data JS function

Returns: JavaScript for parse data function.

generate_populate_function_js()

Generate JavaScript for populate function.

Returns: JavaScript for populate function.

widget = <bluecat.ui_components.wtform_widgets.SuperTableWidget object>

class bluecat.wtform_fields.ValidatingStringField(*args, **kwargs)

Bases: wtforms.fields.simple.StringField bluecat.wtform_fields.extended_field.ExtendedField

StringField with server side validation that can be attached to it, will show green when validated and red when not.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

client_side_validator

JavaScript function name to call when validating field.

classes

Extra HTML classes to append to the element.

kwargs

Other keyword arguments for WTForms Fields.

generate_call_function_js()

Override default JS for call function

Returns: JavaScript function snippet.

generate_clear_below_js()

Add disable all below code.

Returns: JavaScript for clear below JS.

generate_client_and_server_validator()

Adds client and server side validation to a field. Listener for the field must be added separately and should call “populate_<element_id>” when it wants to validate the input.

Returns: JavaScript function code as Python string.

generate_populate_function_js()

Override default JS for populate function

Returns: JavaScript function snippet.

generate_user_input_delay()

Generates generic JavaScript function for adding delay on input.

Returns: The generated JavaScript for adding delay on input.

widget = <bluecat.ui_components.wtform_widgets.SuperTextInput object>

class bluecat.wtform_fields.View(*args, **kwargs)

Bases: bluecat.wtform_fields.simple_autocomplete_field.SimpleAutocompleteField

Autocomplete enabled field for View entities.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

kwargs

Other keyword arguments for WTForms Fields.

class bluecat.wtform_fields.Zone(*args, **kwargs)

Bases: bluecat.wtform_fields.simple_autocomplete_field.SimpleAutocompleteField

Autocomplete enabled field for Zone entities.

Parameters Description
label

HTML label for the generated field.

validators

WTForm validators for the field run on the server side.

kwargs

Other keyword arguments for WTForms Fields.