Package tdi :: Package tools :: Package htmlform :: Module _main :: Class HTMLForm
[frames] | no frames]

Class HTMLForm

source code

object --+
         |
        HTMLForm

HTML form helper class
Instance Methods
 
__init__(self, action=None, method='get', param=None, upload=False, accept_charset='utf-8', xhtml=True, pre_proc=None, post_proc=None)
Initialization
source code
 
form(self, node, hidden=None, hidden_='hidden', autocomplete=None, novalidate=None, raw=False)
Fill in the form starttag
source code
 
hidden(self, node, name, value=None, raw=False)
Render a hidden field
source code
 
text(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, dirname=None, autofocus=None, raw=False)
Render a 'text' input control
 
search(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, dirname=None, autofocus=None, raw=False)
Render a 'search' input control (HTML5)
 
tel(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, autofocus=None, raw=False)
Render a 'tel' input control (HTML5)
 
url(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, autofocus=None, raw=False)
Render a 'url' input control (HTML5)
 
email(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, multiple=None, autofocus=None, raw=False)
Render a 'email' input control (HTML5)
 
password(self, node, name, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, pattern=None, autofocus=None)
Render a 'password' input control
 
datetime(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'datetime' input control (HTML5)
 
date(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'date' input control (HTML5)
 
month(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'month' input control (HTML5)
 
week(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'week' input control (HTML5)
 
time(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'time' input control (HTML5)
 
datetime_local(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'datetime-local' input control (HTML5)
 
number(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'number' input control (HTML5)
 
range(self, node, name, value=None, disabled=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)
Render a 'range' input control (HTML5)
 
color(self, node, name, value=None, disabled=None, autocomplete=None, list=None, autofocus=None, raw=False)
Render a 'color' input control (HTML5)
 
checkbox(self, node, name, value=u'1', selected=None, disabled=None, required=None, autofocus=None)
Render a 'checkbox' input control
 
radio(self, node, name, value, selected=None, disabled=None, required=None, autofocus=None)
Render a 'radio' input control
 
file(self, node, name, accept=None, disabled=None, required=None, multiple=None, autofocus=None)
Render a 'file' input control
 
submit(self, node, name=None, value=None, disabled=None, action=None, enctype=None, method=None, novalidate=None, target=None, autofocus=None)
Render a 'submit' input control
 
image(self, node, name=None, src=None, alt=None, width=None, height=None, disabled=None, action=None, enctype=None, method=None, novalidate=None, target=None, autofocus=None)
Render a 'image' input control
 
reset(self, node, value=None, disabled=None, autofocus=None)
Render a 'reset' input control
 
button(self, node, name=None, value=None, disabled=None, autofocus=None)
Render a 'button' input control
 
textarea(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, placeholder=None, dirname=None, autofocus=None, raw=False)
Render a 'textarea' input control
source code
 
select(self, node, name, options=None, selected=None, option='option', disabled=None, required=None, autofocus=None, multiple=False)
Render a 'select' input control
source code
 
datalist(self, node, id=None, options=None, option='option')
Render a 'datalist' element (especially its options)
source code
 
option(self, node, value, description=None, selected=None, disabled=None, label=None)
Render a single option
source code
 
keygen(self, node, name, keytype=None, challenge=None, disabled=None, autofocus=None)
Render a 'keygen' input control
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
basestring
normalize_newlines(value)
Normalize the newlines of a string
source code
basestring
normalize_whitespaces(value)
Normalize the whitespaces of a string
source code
Properties
  param
Parameter adapter the form is using
  is_xhtml
XHTML flag setting of the form
  is_upload
Upload flag setting of the form
  accept_charset
Accepted charset of the form
  action
Configured form action
  method
Configured form method

Inherited from object: __class__

Method Details

__init__(self, action=None, method='get', param=None, upload=False, accept_charset='utf-8', xhtml=True, pre_proc=None, post_proc=None)
(Constructor)

source code 

Initialization

If you set upload to True, the method will be ignored and be set to post automatically.

Parameters:
  • action (basestring) - Form action URL
  • method (basestring) - form submission method
  • param (ParameterAdapterInterface) - Parameter adapter. If unset or None, no values will be taken out of the request. This is useful for initial requests showing empty forms as there will be no special handling required for this case.
  • upload (bool) - Is this an upload form?
  • accept_charset (basestring) - Accepted charset(s) for submission, if there are multiple charsets given, they have to be unique and space separated.
  • xhtml (bool) - Use XHTML attributes (vs. short attributes)?
  • pre_proc (PreProcInterface) - Pre set node processing callable
  • post_proc (PostProcInterface) - Post set node processing callable
Overrides: object.__init__

normalize_newlines(value)
Static Method

source code 

Normalize the newlines of a string

All newlines are converted to n.

Parameters:
  • value (basestring) - The text to normalize
Returns: basestring
The normalized value, the type depends on the input type

normalize_whitespaces(value)
Static Method

source code 

Normalize the whitespaces of a string

All whitespaces are converted to regular space.

Parameters:
  • value (basestring) - The text to normalize
Returns: basestring
The normalized value, the type depends on the input type

form(self, node, hidden=None, hidden_='hidden', autocomplete=None, novalidate=None, raw=False)

source code 

Fill in the form starttag

The following attributes are possibly set: - action (only if it's not None) - method - accept-charset (only if it's not None) - enctype (only on upload forms) - autocomplete - novalidate

Rendering hidden fields

You can use this method to set a list of hidden fields at once. It iterates over hidden and multiplies the node named by hidden_ accordingly.

The hidden iterable contains tuples of variable length, namely from 1 to 3, like:

[
    ('foo', 'bar'),
    ('zonk', '"plop"', True),
    ('x',),
]

If hidden is empty, the hidden node will be deleted.

Field item tuples

The first (and maybe only) item is the name of the field. This is always set unconditionally.

The second item is the value of the field. If the field does not have a value at all - the second and third items are left out, leaving the name only. If the value is None it's taken out of the request and filled into the field. The third parameter is ignored in this case. If the name does not appear in the request, the field is skipped (not rendered). If the request contains more than one value under that name, a hidden field is generated for each of them. In all other cases the value is written into the value attribute.

The third item determines whether the value should be treated as raw or not. If it's unset, the raw parameter of the method applies.

Parameters:
  • node (tdi.nodetree.Node) - The <form> node
  • hidden (iterable) - Hidden fields to set. If unset or None, no hidden fields are touched. If it's an empty list, the hidden node is removed.
  • hidden_ (basestring) - Name of the hidden field node, relative to the form node (dotted notation)
  • autocomplete (bool) - Set the default autocomplete state of the form (HTML5). If omitted or None, any autocomplete attribute present won't be touched.
  • novalidate (bool) - Set the default novalidate attribute of the form (HTML5). If omitted or None, any novalidate attribute present won't be touched.
  • raw (bool) - Default "rawness" value for the hidden field list

hidden(self, node, name, value=None, raw=False)

source code 

Render a hidden field

Hidden field values are never taken out of the request. The reason for that seemingly inconsistent behaviour is that hidden fields have no assigned semantics. In other words, the method can't know, how to correctly retrieve the value out of the request.

Parameters:
  • node (tdi.nodetree.Node) - The hidden field node
  • name (basestring) - Name of the hidden field
  • value (basestring) - Optional value of the hidden field - if omitted or None, the value attribute is completey removed
  • raw (bool) - Is value raw (not to be escaped)

text(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, dirname=None, autofocus=None, raw=False)

 
Render a 'text' input control
Parameters:
  • node (tdi.nodetree.Node) - The text input node
  • name (basestring) - The name of the text field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • maxlength (int) - Maximum length. If omitted or None, the attribute is deleted.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • pattern (basestring) - Validation pattern (HTML5). If omitted or None, the attribute is left untouched.
  • dirname (basestring) - Direction submission name (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

search(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, dirname=None, autofocus=None, raw=False)

 
Render a 'search' input control (HTML5)
Parameters:
  • node (tdi.nodetree.Node) - The search input node
  • name (basestring) - The name of the search field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • maxlength (int) - Maximum length. If omitted or None, the attribute is deleted.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • pattern (basestring) - Validation pattern (HTML5). If omitted or None, the attribute is left untouched.
  • dirname (basestring) - Direction submission name (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

tel(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, autofocus=None, raw=False)

 
Render a 'tel' input control (HTML5)
Parameters:
  • node (tdi.nodetree.Node) - The tel input node
  • name (basestring) - The name of the tel field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • maxlength (int) - Maximum length. If omitted or None, the attribute is deleted.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • pattern (basestring) - Validation pattern (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

url(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, autofocus=None, raw=False)

 
Render a 'url' input control (HTML5)
Parameters:
  • node (tdi.nodetree.Node) - The url input node
  • name (basestring) - The name of the url field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • maxlength (int) - Maximum length. If omitted or None, the attribute is deleted.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • pattern (basestring) - Validation pattern (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

email(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, pattern=None, multiple=None, autofocus=None, raw=False)

 
Render a 'email' input control (HTML5)
Parameters:
  • node (tdi.nodetree.Node) - The email input node
  • name (basestring) - The name of the email field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • maxlength (int) - Maximum length. If omitted or None, the attribute is deleted.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • pattern (basestring) - Validation pattern (HTML5). If omitted or None, the attribute is left untouched.
  • multiple (bool) - Multiple items allowed? (HTML5) If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

password(self, node, name, maxlength=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, pattern=None, autofocus=None)

 
Render a 'password' input control
Parameters:
  • node (tdi.nodetree.Node) - The password input node
  • name (basestring) - The name of the password field
  • maxlength (int) - Maximum length. If omitted or None, the attribute is deleted.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • pattern (basestring) - Validation pattern (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

datetime(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 

Render a 'datetime' input control (HTML5)

(e.g. 1979-10-14T12:00:00.001-04:00)

Parameters:
  • node (tdi.nodetree.Node) - The datetime input node
  • name (basestring) - The name of the datetime field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

date(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 

Render a 'date' input control (HTML5)

(e.g. 1979-10-14)

Parameters:
  • node (tdi.nodetree.Node) - The date input node
  • name (basestring) - The name of the date field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

month(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 

Render a 'month' input control (HTML5)

(e.g. 1979-10)

Parameters:
  • node (tdi.nodetree.Node) - The month input node
  • name (basestring) - The name of the month field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

week(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 

Render a 'week' input control (HTML5)

(e.g. 1979-W42)

Parameters:
  • node (tdi.nodetree.Node) - The week input node
  • name (basestring) - The name of the week field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

time(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 

Render a 'time' input control (HTML5)

(e.g. 12:00:00.001)

Parameters:
  • node (tdi.nodetree.Node) - The time input node
  • name (basestring) - The name of the time field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

datetime_local(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 

Render a 'datetime-local' input control (HTML5)

(e.g. 1979-10-14T12:00:00.001)

Parameters:
  • node (tdi.nodetree.Node) - The datetime-local input node
  • name (basestring) - The name of the datetime-local field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

number(self, node, name, value=None, readonly=None, disabled=None, required=None, autocomplete=None, placeholder=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 
Render a 'number' input control (HTML5)
Parameters:
  • node (tdi.nodetree.Node) - The number input node
  • name (basestring) - The name of the number field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

range(self, node, name, value=None, disabled=None, autocomplete=None, list=None, min=None, max=None, step=None, autofocus=None, raw=False)

 
Render a 'range' input control (HTML5)
Parameters:
  • node (tdi.nodetree.Node) - The range input node
  • name (basestring) - The name of the range field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • min (basestring) - Minimum value. If omitted or None, the attribute is left untouched.
  • max (basestring) - Maximum value. If omitted or None, the attribute is left untouched.
  • step (basestring) - Step value. If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

color(self, node, name, value=None, disabled=None, autocomplete=None, list=None, autofocus=None, raw=False)

 

Render a 'color' input control (HTML5)

(e.g. #D4D0C8)

Parameters:
  • node (tdi.nodetree.Node) - The color input node
  • name (basestring) - The name of the color field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • autocomplete (bool) - Allow autocompletion? (HTML5). If omitted or None, the attribute is left untouched.
  • list (basestring) - Datalist ID (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

checkbox(self, node, name, value=u'1', selected=None, disabled=None, required=None, autofocus=None)

 
Render a 'checkbox' input control
Parameters:
  • node (tdi.nodetree.Node) - The checkbox input node
  • name (basestring) - The name of the checkbox field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string.
  • selected (bool) - This option is used to determine whether the control is checked or not. It's a three-way-boolean: yes, no, maybe :-). If unset or None it's "maybe" and taken out of the request. Otherwise the boolean value determines the initial state of the control.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

radio(self, node, name, value, selected=None, disabled=None, required=None, autofocus=None)

 
Render a 'radio' input control
Parameters:
  • node (tdi.nodetree.Node) - The radio input node
  • name (basestring) - The name of the radio field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string.
  • selected (bool) - This option is used to determine whether the control is checked or not. It's a three-way-boolean: yes, no, maybe :-). If unset or None it's "maybe" and taken out of the request. Otherwise the boolean value determines the initial state of the control.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

file(self, node, name, accept=None, disabled=None, required=None, multiple=None, autofocus=None)

 
Render a 'file' input control
Parameters:
  • node (tdi.nodetree.Node) - The file input node
  • name (basestring) - The name of the file field
  • accept (iterable) - The list of accepted mime-types, if it's None, the corresponding attribute won't be touched ([u'type', ...])
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • multiple (bool) - Multiple items allowed? (HTML5) If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

Note: This is only possible if the class was initialized with upload=True.

submit(self, node, name=None, value=None, disabled=None, action=None, enctype=None, method=None, novalidate=None, target=None, autofocus=None)

 
Render a 'submit' input control
Parameters:
  • node (tdi.nodetree.Node) - The submit input node
  • name (basestring) - The name of the submit field
  • value (basestring) - The value of the control. If unset or None, it's left untouched
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • action (basestring) - formaction modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • enctype (basestring) - formenctype modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • method (basestring) - formmethod modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • novalidate (bool) - formnovalidate modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • target (basestring) - formtarget modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

image(self, node, name=None, src=None, alt=None, width=None, height=None, disabled=None, action=None, enctype=None, method=None, novalidate=None, target=None, autofocus=None)

 
Render a 'image' input control
Parameters:
  • node (tdi.nodetree.Node) - The image input node
  • name (basestring) - The name of the image field
  • src (basestring) - Image source URL. If unset or None, it's left untouched.
  • alt (basestring) - Alternative text for the image. If unset or None, it's left untouched.
  • width (int) - Width of the image. If unset or None, the attribute is left untouched.
  • height (int) - Height of the image. If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • action (basestring) - formaction modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • enctype (basestring) - formenctype modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • method (basestring) - formmethod modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • novalidate (bool) - formnovalidate modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • target (basestring) - formtarget modifier of the control (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

reset(self, node, value=None, disabled=None, autofocus=None)

 
Render a 'reset' input control
Parameters:
  • node (tdi.nodetree.Node) - The reset input node
  • value (basestring) - The value of the control. If unset or None, it's left untouched
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

button(self, node, name=None, value=None, disabled=None, autofocus=None)

 
Render a 'button' input control
Parameters:
  • node (tdi.nodetree.Node) - The button input node
  • name (basestring) - The name of the button field
  • value (basestring) - The value of the control. If unset or None, it's left untouched
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

textarea(self, node, name, value=None, maxlength=None, readonly=None, disabled=None, required=None, placeholder=None, dirname=None, autofocus=None, raw=False)

source code 
Render a 'textarea' input control
Parameters:
  • node (tdi.nodetree.Node) - The 'textarea' node
  • name (basestring) - The name of the 'textarea' field
  • value (basestring) - Optional value. If None, it's taken out of the request. If it does not appear in the request, it's treated like an empty string. The raw parameter is ignored in this case.
  • maxlength (int) - Maximum length. If omitted or None, the attribute is deleted.
  • readonly (bool) - Readonly field? If unset or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • placeholder (basestring) - Placeholder value (HTML5). If omitted or None, the attribute is left untouched.
  • dirname (basestring) - Direction submission name (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • raw (bool) - Is the value to be treated raw?

select(self, node, name, options=None, selected=None, option='option', disabled=None, required=None, autofocus=None, multiple=False)

source code 

Render a 'select' input control

This method actually renders two nodes, namely the select element and the option element:

<select tdi="node">
     <option tdi="*option">foo</option>
</select>

The option node is repeated as necessary (matching the entries of the options parameter). If options is empty, the whole select node is emptied. The option is usually flagged with an asterisk, so it doesn't trigger an automatic render-method call.

Parameters:
  • node (tdi.nodetree.Node) - The 'select' input node
  • name (basestring) - The name of the 'select' field
  • options (iterable) - The list of option values. Each item is expected to be a 2-tuple of the option value and its description. The value is what's put into the option's value attribute and submitted by the browser if the option is selected. The description is the visible part of the option. If the value is None, it's treated unset and the description is submitted as selected value instead. If options is None, only the select element will be touched.
  • selected (basestring or iterable) - The pre-selected value. If it's unset or None, it's taken out of the request. If it does not appear in the request, there just won't be any pre-selected option. If multiple is true, selected is expected to be an iterable of basestrings.
  • option (str) - The node of the option node, relative to the select node. The parameter is expected in dotted notation.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • required (bool) - Required field? (HTML5). If omitted or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.
  • multiple (bool) - Is it a multiselect box? selected is expected to be an iterable containing multiple selected values in this case.

datalist(self, node, id=None, options=None, option='option')

source code 

Render a 'datalist' element (especially its options)

This method actually renders two nodes, namely the datalist element and the option element:

<datalist tdi="node">
     <option tdi="*option" />
</datalist>

The option node is repeated as necessary (matching the entries of the options parameter). If options is empty, the whole datalist node is emptied. The option is usually flagged with an asterisk, so it doesn't trigger an automatic render-method call.

Parameters:
  • node (tdi.nodetree.Node) - The 'datalist' node
  • id (basestring) - The id attribute of the 'datalist' field. If omitted or None, the attribute is left untouched.
  • options (iterable) - The list of option values. Each item is expected to be a 2-tuple of the option value and its description. The value is what's put into the option's value attribute. The description is the visible part of the option and put into the 'label' attribute. If the value is None, it's treated as unset. If options is None, only the datalist element will be touched.
  • option (str) - The node of the option node, relative to the select node. The parameter is expected in dotted notation.

option(self, node, value, description=None, selected=None, disabled=None, label=None)

source code 
Render a single option
Parameters:
  • node (tdi.nodetree.Node) - The option node
  • value (basestring) - The option value, if None, the attribute will be removed.
  • description (basestring) - The visible part of the option. If omitted or None, the element's content is left untouched.
  • selected (bool) - Is the option selected? If unset or None the attribute will be left untouched.
  • disabled (bool) - Is this option disabled? If unset or None, the attribute will be left untouched.
  • label (basestring) - Label attribute (HTML5). If omitted or None, any existing attribute is deleted.

keygen(self, node, name, keytype=None, challenge=None, disabled=None, autofocus=None)

source code 
Render a 'keygen' input control
Parameters:
  • node (tdi.nodetree.Node) - The 'keygen' node
  • name (basestring) - The name of the 'keygen' field
  • keytype (basestring) - Optional keytype. If omitted or None, the attribute is left untouched.
  • challenge (basestring) - Optional challenge value. If omitted or None, the attribute is left untouched.
  • disabled (bool) - Disabled field? If unset or None, the attribute is left untouched.
  • autofocus (bool) - Set autofocus? (HTML5). If omitted or None, the attribute is left untouched.

Property Details

param

Parameter adapter the form is using
Get Method:
unreachable.param(self) - Parameter adapter getter

is_xhtml

XHTML flag setting of the form
Get Method:
unreachable.is_xhtml(self) - XHTML flag getter

is_upload

Upload flag setting of the form
Get Method:
unreachable.is_upload(self) - Upload flag getter

accept_charset

Accepted charset of the form
Get Method:
unreachable.accept_charset(self) - Accept-charset getter

action

Configured form action
Get Method:
unreachable.action(self) - Form action getter

method

Configured form method
Get Method:
unreachable.method(self) - Form method getter