pywebtools.kajiki – Utilities for use with Kajiki

This module provides two function definition templates “form.kajiki” and “menu.kajiki”.

form.kajiki

Helper functions for creating HTML input elements.

pywebtools.kajiki.input(field_type, field_name, **kwargs)

Generates a HTML input field with the given field_type and field_name. The kwargs contains additional parameters:

* value: The default value or the value of a checkbox/radio/select input
* values: List of (value, label) pairs for use with a select input
* extra_attrs: Dictionary of additional HTML element attribute key/value pairs

Additionally if a values dictionary is in the current view, then this will be used to set any input values. This can be used to pre-fill the form with existing data.

Parameters:
  • field_type (str) – The HTML field type to generate
  • field_name (str) – The name of the HTML field
  • kwargs – Additional keyword arguments as described above
pywebtools.kajiki.field(field_type, field_name, field_label, **kwargs)

Generates a HTML input field with wrapping <label> using the field_label value. Sets Foundation / Abide CSS classes if there is an errors dictionary in the current view and the field_name occurs in that dictionary. Will also output the matching error message.

Parameters:
  • field_type (str) – The HTML field type to generate
  • field_name (str) – The name of the HTML field
  • field_name – The displayed label of the HTML field
  • kwargs – Additional keyword arguments as described in input()
pywebtools.kajiki.csrf_field()

Generates a hidden input field with the name “csrf_token” and the value set to the current session’s CSRF token. Integrates with the pywebtools.formencode.CSRFSchema.