| |
- exceptions.Exception(exceptions.BaseException)
-
- FormException
-
- ContentLengthExceeded
- InvalidFormEncoding
- InvalidRequestMethod
- InvalidValueFormat
- InvalidValueLen
- ParamsMissing
- TooManyValues
- UndeclaredFieldName
- Field
-
- Checkbox
- Input
-
- File
- HiddenInput
- Password
- Keygen
- Radio
-
- Select
- Textarea
- Form
class Checkbox(Field) |
|
Check boxes:
<input type="checkbox"> |
|
Methods defined here:
- __init__(self, name, text, maxValues=1, required=0, accessKey='', default=None, checked=0)
- pattern and maxLen are determined by default
- inputHTML(self, default=None, id_value=None, title=None, checked=None)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
|
class Field |
|
Base class for all kind of single input fields.
In most cases this class is not used directly
since derivate classes for most types of input fields exist. |
|
Methods defined here:
- __init__(self, name, text, maxLen, maxValues, pattern, required=0, default=None, accessKey='')
- name
Field name used in <INPUT NAME="..">
text
User-friendly text describing this field
maxLen
maximum length of a single input value [Bytes]
maxValues
maximum amount of input values
default
default value to be used in method inputfield()
required
flag which marks field as mandantory input field
accessKey
key for accessing this field to be displayed by method inputHTML()
pattern
regex pattern of valid values either as string
or tuple (pattern,options)
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
|
class File(Input) |
|
File upload field
<input type="file"> |
|
- Method resolution order:
- File
- Input
- Field
Methods defined here:
- inputHTML(self, default=None, id_value=None, title=None, mimeType=None)
Data and other attributes defined here:
- mimeType = 'application/octet-stream'
Methods inherited from Input:
- __init__(self, name, text, maxLen, maxValues, pattern, required=0, default=None, accessKey='', size=None)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
|
class Form |
|
Class for declaring and processing a whole <form> |
|
Methods defined here:
- __init__(self, inf, env)
- Initialize a Form
inf Read from this file object if method is POST.
env Dictionary holding the environment vars.
- addField(self, f)
- Add a input field object f to the form.
- checkRequestMethod(self)
- Checks whether the HTTP request method is accepted
- getContentType(self)
- Determine the HTTP content type of HTTP request
- getInputFields(self, ignoreEmptyFields=0, ignoreUndeclaredFields=0, stripValues=1, unquotePlus=0)
- Process user's <form> input and store the values in each
field instance's content attribute.
When a processing error occurs FormException (or derivatives)
are raised.
ignoreEmptyFields=0 Ignore fields with empty input.
ignoreUndeclaredFields=0 Ignore fields with names not declared.
Normally UndeclaredFieldName is raised.
stripValues=1 If true leading and trailing whitespaces
are stripped from all input values.
unquotePlus=0
If non-zero urllib.unquote_plus() is used instead of urllib.unquote().
- getInputValue(self, name, default=[])
- Return input value of a field defined by name if presented
in form input. Return default else.
- hiddenInputFields(self, outf=<open file '<stdout>', mode 'w'>, ignoreFieldNames=None)
- Output all parameters as hidden fields.
outf
File object for output.
ignoreFieldNames
Names of parameters to be excluded.
|
class HiddenInput(Input) |
|
Hidden input field:
<input type="hidden"> |
|
- Method resolution order:
- HiddenInput
- Input
- Field
Methods defined here:
- __init__(self, name, text, maxLen, maxValues, pattern, required=0, default=None, accessKey='')
- inputHTML(self, default=None, id_value=None, title=None, show=0)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
|
class Input(Field) |
|
Normal one-line input field:
<input> |
|
Methods defined here:
- __init__(self, name, text, maxLen, maxValues, pattern, required=0, default=None, accessKey='', size=None)
- inputHTML(self, default=None, id_value=None, title=None)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
|
class Keygen(Field) |
|
Select field for client-side key generation with
Netscape/Mozilla/Opera browser:
<KEYGEN> |
|
Methods defined here:
- __init__(self, name, text, maxLen, maxValues, required=0, minKeyLength=512)
- inputHTML(self, challenge, id_value=None, title=None)
- valueHTML(self)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
|
class Password(Input) |
|
Password input field:
<input type="password"> |
|
- Method resolution order:
- Password
- Input
- Field
Methods defined here:
- inputHTML(self, default=None, id_value=None, title=None)
- valueHTML(self)
- For security reasons only stars are printed
Methods inherited from Input:
- __init__(self, name, text, maxLen, maxValues, pattern, required=0, default=None, accessKey='', size=None)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
|
class Radio(Field) |
|
Radio buttons:
<input type="radio"> |
|
Methods defined here:
- __init__(self, name, text, maxValues=1, required=0, default=None, accessKey='', options=None)
- pattern and maxLen are determined from __init__ params
Additional parameters:
options=[]
List of options. Either just a list of strings
['value1','value2',..] for simple options
or a list of tuples of string pairs
[('value1','description1),('value2','description2),..]
for options with different option value and description.
- inputHTML(self, default=None, id_value=None, title=None)
- setDefault(self, default)
- Set the default of a default field.
Mainly this is used if self.default shall be changed after
initializing the field object.
- setOptions(self, options)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
|
class Select(Radio) |
|
Select field:
<select multiple>
<option value="value">description</option>
</select> |
|
- Method resolution order:
- Select
- Radio
- Field
Methods defined here:
- __init__(self, name, text, maxValues, required=0, default=None, accessKey='', options=None, size=1, ignoreCase=0, multiSelect=0)
- Additional parameters:
size
Integer for the size of displayed select field.
ignorecase
Integer flag. If non-zero the case of input strings is ignored
when checking input values.
multiSelect
Integer flag. If non-zero the select field has HTML attribute
"multiple" set.
- inputHTML(self, default=None, id_value=None, title=None)
Methods inherited from Radio:
- setDefault(self, default)
- Set the default of a default field.
Mainly this is used if self.default shall be changed after
initializing the field object.
- setOptions(self, options)
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setRegex(self, pattern)
- Set the regex pattern for validating this field.
Mainly this is used if self._re shall be changed after
the field object was initialized.
pattern
Either a string containing a regex pattern,
a tuple (pattern string, pattern options) or None.
If None regex checking in _validateFormat is switched off
(not recommended).
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
|
class Textarea(Field) |
|
Multi-line input field:
<textarea> |
|
Methods defined here:
- __init__(self, name, text, maxLen, maxValues, pattern, required=0, default=None, accessKey='', rows=10, cols=60)
- inputHTML(self, default=None, id_value=None, title=None)
- Returns string with HTML input field.
- setRegex(self, pattern)
- Like Field.setRegex() but pattern options re.S and re.M are
automatically added.
- valueHTML(self)
- HTML output of self.value using the HTML template string
in self.valueHTMLTemplate.
Methods inherited from Field:
- getValue(self)
- Returns self.value in case of multi-valued input or
self.value[0] if only one value is allowed.
- idAttrStr(self, id_value)
- labelHTML(self, labelText=None, for_value=None)
- setCharset(self, charset)
- Define the character set of the user's input.
- setDefault(self, default)
- Set the default of a field.
Mainly this is used by the application if self.default shall
be changed after initializing the field object.
- setValue(self, value)
- Store the user's value into the field object.
This method can be used to modify the user's value
before storing it into self.value.
- titleHTML(self, title)
- HTML output of default.
|
|