This module provides fields to support the following data types:
||A character field taking strings of length 1|
||A string field taking strings of up to 255 characters|
||A text field for storing large amounts of text (up to 16k characters)|
||An integer field taking any integer that is a valid Python integer (but not long)|
||A float field taking Python float values|
||A date field. Takes values in the form of python datetime objects. Only stores days, months and years, any other information is trunkated. Dates from |
||A time field. Takes values in the form of python datetime objects. Only stores hours, minutes and seconds, any other information is trunkated.|
||A datetime field. Takes values in the form of python datetime objects. Only stores days, months, years, hours, minutes and seconds, any other information is trunkated.|
Note: These Field objects correspond to the fields used by the web.database module. There is a reason for this; the Column objects in the web.database.object module are each derived from a web.form.field.typed Field. This means that columns from a web.database.object.Row are also valid form fields. This is used in the web.database.object classes to automatically generate and validate forms which can be used seamlessly and easily submit and edit data in a database.
Each of the data types listed below has three types of field specified:
The typed field classes have the same interface as their basic equivalents except that:
1. The Select and CheckBoxGroup classes take lists of their respective data types rather than
value, label pairs.
2. The fields return their repsective Python object (or list of objects) when their
.value attribute is called.
All the fields can either take their respective data type or the value
None as possible values for the field. The only complications are the web.form.field.typed.String, web.form.field.typed.Text and classweb.form.field.typed.Char objects.
If someone enters no information into a String field there is a choice of whether to treat this as a null string
'' or a NULL value
None. To specify which behaviour you would like the
web.form.field.typed.String object accepts the parameter treatNullStringAsNone which takes a default value of
web.form.field.typed.Text fields also accept the treatNullStringAsNone parameter.
web.form.field.typed.Integer field also takes the parameters min and max to specify the minimum and maximum values and the parameters minError and maxError to specify the errors to display if the values are outside the specified minimum and maximum.
One more complication is how to display
None values in the web.form.field.typed.StringSelect and classweb.form.field.typed.CharSelect objects. If you choose the string
'None' to display it how do you distinguish
'None'? Any value you choose could be confused with another string. The solution is to set a string value to dispaly
None that isn't another value in the options. You can set this using the displayNoneAs parameter.
None values for the other Select fields are just displayed as