A collection of Button instances.
An HTML <input type=”checkbox”> control. self.value is always valid and the merged value is boolean.
HTML TD tag.
Output HTML for a value which which can be loaded from another object.
Override this method to provide any required formatting or modification of the displayed value.
This should return the correctly typed object to update the field in the original object. Override this if you are using a non-string value.
Return the converted value in this field
A collection of named CSS styles used in the HTML output of HTMLTag instances.
Each Form has a reference to a single instances of this class - field.styles.
The default style names are:
Base class for input fields.
Creating your own Field-subclasses
Several methods may be provided by custom subclasses as needed:
should return the value stored in self.value to how you want it displayed in the browser. This is typically called during to_html and the value of self.value will be replaced with this after that point.
Should convert the string version of the value passed in and return a value of the appropriate type.
Generate custom HTML for this tag. Use:
form.write_content(ctx, ‘<your html here>’)
to write your HTML to the output stream.
Override get_merge_value() where the value received from Albatross on a form submission should be checked or modified before being stored.
Create a unique string representation of the field to be used as an Albatross input name.
Load self.value from a named attribute in the model.
Merge value back into the model.
Field subclasses must provide different output for static, enabled and disabled states and may output validation error messages.
The default implementation of write_static_html() and write_errors_html() should suffice for most cases. A typical subclass will override write_form_html() to provide the HTML ouput for the input controls required (text input, checkbox, etc.)
Subclasses should use this method to validate s after form submission. The method should raise a FieldValidationError for invalid values.
Write the interactive form control HTML representation of the field.
Raised by Field subclasses if validate() fails.
Container for a collection of Field instances.
Writes a table of fields. Note that the <fieldset> HTML tags are intentionally provided by the FieldsetForm and not this class.
A Form subclass which wraps the HTML output in a <FIELDSET> tag.
A TextField which validates and merges float values.
Encapsulates an HTML form and its input fields.
Clear all field values, set form and all fields to valid state, clear disabled and set edit mode to FORM_CREATE.
Clear errors and set all fields to valid.
Load field values from load_obj.
Merge all field values to merge_obj.
Called by alx-form tag handler to render the form. This method sets the correct internal state for rendering, resets indentation and registers input fields before calling to_html().
Disable or enable data entry on all fields on this form.
Render all fields and buttons as HTML. This is an internal method. To render the form use run().
Call validate() on each field. Sets self.valid to False and raises FormValidationError if any fields are invalid. Validation exceptions are stored in self.validation_errors and are cleared by calling clear(), clear_errors() or on the next call to validate().
Static fields or fields of a static form are not validated.
A wrapper for ctx.write_content() which provides indentation to assist in generating human readable HTML output.
Valid values for indent are:
All other values are ignored.
Base class for all exceptions raised by the albatross.ext.form module.
Convenience class for simple form/model manipulation.
Collect the attributes we’re interested in from the alx-form tag.
Raised by Form subclasses validation fails for one or more fields.
Base class for any class which provides HTML output. Arbitrary HTML attributes can be specified as html_attrs.
An HTMLTag with children.
HTML TH tag.
Base class for generating an HTML <input> tag. Requires that the instance has a self.type which is the type of the HTML input, ie, it will generate <input type=”(self.type)” ...>.
Subclasses are expected to maintain self.value as the correct type (eg, string (for text), int, datetime, etc) and to do validation of the input as required. Self.value can also contain invalid strings if the user has partly edited a field. Calling merge or get_value before validate has succeeded may raise an exception.
The conversion of the internal value to the display value is complicated because Albatross sets the value of an empty field to None so that needs to be handled or all empty text fields in a form are converted to “None”.
A InputField which validates and merges integer values.
Create an HTML table from a list of objects.
table_attr is the name of the instance var in the class which creates this object. This is used when directing Albatross to update the form values.
row_class is a subclass of IteratorTableRow. It is used to render each row in the table. It will be used to contruct each row by being instantiated with each element of content_list in turn.
If you need pass the row class constructor some extra arguments from the table constructor, assign them to instance variables and make the row_class a bound method to a method that marshalls the arguments before calling the row constructor.
data to display in the table.
Append a new item of data to the table
Jump to specified page. If page == -1, go to last page.
Remove an item of data from the table
Update an item of data in the table
When using an IteratorTable, the class that’s used to display each row must be a subclass of IteratorTableRow so that the rendering and validation is performed correctly. This is checked for in the IteratorTable constructor.
Each row in a table is actually treated as a separate sub-Form. This allows Albatross to traverse the table hierarchy when it’s updating the field values.
generates the row’s content bracketed by <tr>/</tr>
Simple displayed string value with no label.
Build a two column Row instance with a name Label and a Field.
Base class to handle selection of a single value from a list of options, ie, for a select or radio list.
change the options displayed by the select field.
Base class for displaying page selection
Simple pager which stores all items and returns the items for a given page in a @row_class instance on demand.
An IteratorTable item list which supports pagination. Subclasses should implement page_count() and items_on_page() to create @row_class instances of the items for a given page on demand.
A TextField with text input hidden by ‘*’
Manage a radio list.
When the field or the enclosing form is static, we just emit the selected option. (XXX I hope that’s the right thing to do)
HTML TR tag.
Manage a drop down list of options.
String Field which never accepts user input.
HTML TABLE tag.
HTML <input type=”text”> tag. Merged data is a string. If self.required is True validate() will raise a FieldValidationError if the input field is empty. No other validation or conversion is performed.
Empty input field is submitted as None - convert to empty string.