spug.web.form
index
/home/mmuller/w/spug/web/form.py

Contains classes for building web forms.

 
Modules
       
web.htmlo
weakref

 
Classes
       
exceptions.Exception(exceptions.BaseException)
web.form.FieldValidationError
web.form.FieldInfo
web.form.FormModel
web.form.DefaultModel
web.form.SubmissionResult
web.form.DefaultSubmissionResult
web.htmlo.XNull(web.htmlo.HTMLElement)
web.form.FieldError
web.form.FormControl
web.form.DefaultFormChoice
web.form.DefaultFormEntry
web.form.FormButton
web.form.DefaultResetButton
web.form.DefaultSubmitButton
web.form.FormGroup
web.form.DefaultFormGroup
web.form.Form
web.form.DefaultForm
web.wof.Node
web.form.FormNode
web.form.TestNode

 
class DefaultForm(Form)
    Default form elemlet.  Implements a form as an HTML form with elements
layed out in a table.  The table element is of class "formTable".
 
 
Method resolution order:
DefaultForm
Form
FormGroup
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
__init__(self, request)
addControl(self, control)
setAction(self, action)
setLastPage(self, lastPage)
setMethod(self, method)

Methods inherited from FormGroup:
addChoice(self, name, label=None, options=[], value=None)
Adds a new "choice" control to the form.
 
parms:
   name::
      [string] choice control name.
   label::
      [string or None] label associated with the choice
   options::
      [list<string>] list of options
   value::
      [string or None] selected item in the list of options.
addEntry(self, name, width=None, label=None, required=1, secret=0)
Adds an entry control to the group.  The entry control is obtained
from the "form.entry.required" or "form.entry.optional" method,
depending on whether the entry is required or optional.
 
parms:
   name::
      [string] entry name.  This is the name by which the entry
      control will be accessed.
   width::
      [int or None] if not *None*, this is the field width.
   label::
      [string or None] if specified, this is the entry field label.
   required::
      [boolean] if true, this entry is a required field, and will
      be annotated as such.
   secret::
      [boolean] if true, the entry is a "password" entry (input
      is obscured).
addGroup(self, style='form')
Adds a new "control group".  This can be used to group a set of
controls together.  The new group object is returned.
 
The new group object is obtained from the "form.group./style/"
property if defined, then the "form.group" property, and
finally @DefaultFormGroup is used by default.
 
parms::
   style::
      [string] group display style.  Generally accepted styles
      are:
      
         form::
            Outer form.
         buttons::
            button panel.
      
      Other styles may be defined for richer forms.
addResetButton(self, label=None)
Adds a reset button to the group.  The reset button is obtained
from the "form.reset" property, a @DefaultResetButton instance
is used by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be
      placed on the button.  This can also be obtained from the
      value of the "form.reset.label" property, and "Reset" is
      used by default.
addSubmitButton(self, label=None)
Adds a submit button to the group.  The submmit button is obtained
from the "form.submit" property, a @DefaultSubmitButton instance
by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be placed
      on the button.  This can also be obtained from the value
      of the "form.submit.label" property, and "Done" is used
      by default.
setFields(self, fields)
Sets the "fields" dictionary.  This is used to lookup field
parameters that are not specified in the control methods.
 
parms:
   fields::
      [dict<string, @FieldInfo>]  Dictionary mapping field names
      to field information objects.

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class DefaultFormChoice(FormControl)
    
Method resolution order:
DefaultFormChoice
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
__init__(self, request)
addOption(self, option)
setLabel(self, label)
setName(self, name)
setValue(self, value)

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class DefaultFormEntry(FormControl)
    
Method resolution order:
DefaultFormEntry
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
__init__(self, request)
setLabel(self, label)
setName(self, name)
setSecret(self, secret)
setValue(self, value)
setWidth(self, width)

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class DefaultFormGroup(FormGroup)
    Default implementation of a form control group.  No special HTML
formatting is added: it remains a null group, so therefore
flow layout should take effect.
 
 
Method resolution order:
DefaultFormGroup
FormGroup
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
addControl(self, control)

Methods inherited from FormGroup:
__init__(self, request, *parms)
addChoice(self, name, label=None, options=[], value=None)
Adds a new "choice" control to the form.
 
parms:
   name::
      [string] choice control name.
   label::
      [string or None] label associated with the choice
   options::
      [list<string>] list of options
   value::
      [string or None] selected item in the list of options.
addEntry(self, name, width=None, label=None, required=1, secret=0)
Adds an entry control to the group.  The entry control is obtained
from the "form.entry.required" or "form.entry.optional" method,
depending on whether the entry is required or optional.
 
parms:
   name::
      [string] entry name.  This is the name by which the entry
      control will be accessed.
   width::
      [int or None] if not *None*, this is the field width.
   label::
      [string or None] if specified, this is the entry field label.
   required::
      [boolean] if true, this entry is a required field, and will
      be annotated as such.
   secret::
      [boolean] if true, the entry is a "password" entry (input
      is obscured).
addGroup(self, style='form')
Adds a new "control group".  This can be used to group a set of
controls together.  The new group object is returned.
 
The new group object is obtained from the "form.group./style/"
property if defined, then the "form.group" property, and
finally @DefaultFormGroup is used by default.
 
parms::
   style::
      [string] group display style.  Generally accepted styles
      are:
      
         form::
            Outer form.
         buttons::
            button panel.
      
      Other styles may be defined for richer forms.
addResetButton(self, label=None)
Adds a reset button to the group.  The reset button is obtained
from the "form.reset" property, a @DefaultResetButton instance
is used by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be
      placed on the button.  This can also be obtained from the
      value of the "form.reset.label" property, and "Reset" is
      used by default.
addSubmitButton(self, label=None)
Adds a submit button to the group.  The submmit button is obtained
from the "form.submit" property, a @DefaultSubmitButton instance
by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be placed
      on the button.  This can also be obtained from the value
      of the "form.submit.label" property, and "Done" is used
      by default.
setFields(self, fields)
Sets the "fields" dictionary.  This is used to lookup field
parameters that are not specified in the control methods.
 
parms:
   fields::
      [dict<string, @FieldInfo>]  Dictionary mapping field names
      to field information objects.

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class DefaultModel(FormModel)
    Simple @FormModel which delegates all processing back to the @FormNode
instance.  This will be used if no model object is specified.
 
  Methods defined here:
__init__(self, formNode)
parms:
   formNode::
      [@FormNode] window to use as a source.
getFields(self, request)
Implements @FormModel.getFields()
submit(self, request)
Implements @FormModel.submit()

Methods inherited from FormModel:
validate(self, request, errorList)
Used to validate form submissions.  This is called prior to 
@submit().  If it returns false, there was at least
one validation error and @emitErrorPage() will be called instead.
 
This method iterates over the field set (as defined by the
/fields/ instance variable) and calls the @FieldInfo.validate()
method for each field in it.
 
May be overriden by derived classes, if so, you probably want
to call this method first.
 
parms:
   request::
      [@spugweb.Request] the initial request object
   errorList::
      [list<string or @spug.web.htmlo.HTMLElement>] This is an
      output parameter: an empty list should be passed in.
      If there are validation errors, they will be added to this
      list.

 
class DefaultResetButton(FormButton)
    
Method resolution order:
DefaultResetButton
FormButton
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
__init__(self, request)

Methods inherited from FormButton:
setLabel(self, label)

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class DefaultSubmissionResult(SubmissionResult)
    Simple implementation of @SubmissionResult.
 
  Methods defined here:
__init__(self, result=None, errors=None, exception=None, actionsCompleted=None)
Callers will usuallly want to pass in either the /result/ or 
/errors/ parameter, but using all default parameters is acceptable.
If /errors/ is not-None, it means that there was an error and
/result/ should be *None*.
 
parms:
   result::
      [any or None] python data object to use as a result.
   errors::
      [list<string or @FieldError> or None] list of displayable errors
   exception::
      [Exception or None] a python exception object.  This should
      be used to transmit an exception if there were errors resulting
      from an exception.
   actionsCompleted::
      [list<string or @htmlo.Element> or None] list of completed
      actions (normally displayed on submission page.
getActionsCompleted(self)
Returns the actions completed.  If this value is not passed in
during constructed, a list containing the standard string,
"Request Submitted" is returned.
getErrors(self)
Implements @SubmissionResult.getErrors()
getException(self)
Returns the python Exception instance associated with the errors
or *None*.
 
XXX might want to make this part of @SubmissionResult, but not yet.
getResult(self)
Implements @SubmissionResult.getResult()

 
class DefaultSubmitButton(FormButton)
    
Method resolution order:
DefaultSubmitButton
FormButton
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
__init__(self, request)

Methods inherited from FormButton:
setLabel(self, label)

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class FieldError(web.htmlo.XNull)
    An elemlet for field validation errors.  This is an abstract base
class to allow these errors to be implemented as something other
than a simple string.
 
 
Method resolution order:
FieldError
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
setExtra(self, extra)
Sets the "extra parameter" to be used in the error message.
 
Must be implemented by derived class.
 
parms:
   extra::
      [any] extra parameter
setLabel(self, label)
Sets the field label to be used in the error message.
 
Must be implemented by derived class.
 
parms:
   label::
      [string] the field label

Methods inherited from web.htmlo.HTMLElement:
__init__(self, *parms, **kw)
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class FieldInfo
    Provides information about a field definition.
 
Public-vars:
   name::
      [string] field name.  This is the name used for the field
      in the form.
   label::
      [string] field label.  This is the human recognizable name of
      the field, and may vary in the representation of the form
      in other languages.
   minLength::
      [int] minimum field length.  If 0, this is ignored.
   maxLength::
      [int] maximum field length.  If 0, this is ignored.
   ignoreWS::
      [boolean] if true, leading and trailing whitespace is ignored
      for the field and its value.
   options::
      [list<string> or None]  If not *None*, this is a list of
      valid value options for this field.
   required::
      [boolean] if true, this is a required field
   secret::
      [boolean] if true, this is a secret field (its contents is 
      unreadable)
 
  Methods defined here:
__init__(self, name, label=None, minLength=0, maxLength=0, ignoreWS=0, options=None, required=0, secret=0)
validate(self, value)
Validates the field and returns the field value with any necessary
transforms applied.  Raises a @FieldValidationError on failure.

 
class FieldValidationError(exceptions.Exception)
    Raised when the value of the field is illegal.  Exception text
is a good standard description of the error.
 
Public-vars:
   fieldId::
      [string] Name of the field that failed validation.
   fieldLabel::
      [string] Text label of the field that failed validation.
   errorId::
      [string] Coded label specifying the error.  This should be a
      property name so that the error string can be looked up.
   extra::
      [any] Extra parameter for error string generation.  This varies
      depending on the nature of the error, if the value is not long
      enough, it is the minimum length.  If it it too long, it is the
      maximum length.
 
 
Method resolution order:
FieldValidationError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, fieldId, fieldLabel, errorId, text, extra=None)

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8140ce0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class Form(FormGroup)
    
Method resolution order:
Form
FormGroup
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
__init__(self, request, *parms)
setAction(self, action)
Defines the form's action URL.
 
Must be implemented by derived class.
 
parms:
   action::
      [string] the action URL.
setLastPage(self, lastPage)
Creates a hidden "_lastPage" input on the form to allow the 
submission page to display the last location.
 
parms:
   lastPage::
      [string] last page URL.
setMethod(self, method)
Defines the form's submission method.
 
Must be implemented by derived class.
 
parms:
   method::
      [string] the form submission method, normally "GET" or "POST".

Methods inherited from FormGroup:
addChoice(self, name, label=None, options=[], value=None)
Adds a new "choice" control to the form.
 
parms:
   name::
      [string] choice control name.
   label::
      [string or None] label associated with the choice
   options::
      [list<string>] list of options
   value::
      [string or None] selected item in the list of options.
addControl(self, control)
Adds a form control to the group.
 
Muet be implemented by derived class.
 
parms:
   control::
      [@FormControl] control to be added.
addEntry(self, name, width=None, label=None, required=1, secret=0)
Adds an entry control to the group.  The entry control is obtained
from the "form.entry.required" or "form.entry.optional" method,
depending on whether the entry is required or optional.
 
parms:
   name::
      [string] entry name.  This is the name by which the entry
      control will be accessed.
   width::
      [int or None] if not *None*, this is the field width.
   label::
      [string or None] if specified, this is the entry field label.
   required::
      [boolean] if true, this entry is a required field, and will
      be annotated as such.
   secret::
      [boolean] if true, the entry is a "password" entry (input
      is obscured).
addGroup(self, style='form')
Adds a new "control group".  This can be used to group a set of
controls together.  The new group object is returned.
 
The new group object is obtained from the "form.group./style/"
property if defined, then the "form.group" property, and
finally @DefaultFormGroup is used by default.
 
parms::
   style::
      [string] group display style.  Generally accepted styles
      are:
      
         form::
            Outer form.
         buttons::
            button panel.
      
      Other styles may be defined for richer forms.
addResetButton(self, label=None)
Adds a reset button to the group.  The reset button is obtained
from the "form.reset" property, a @DefaultResetButton instance
is used by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be
      placed on the button.  This can also be obtained from the
      value of the "form.reset.label" property, and "Reset" is
      used by default.
addSubmitButton(self, label=None)
Adds a submit button to the group.  The submmit button is obtained
from the "form.submit" property, a @DefaultSubmitButton instance
by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be placed
      on the button.  This can also be obtained from the value
      of the "form.submit.label" property, and "Done" is used
      by default.
setFields(self, fields)
Sets the "fields" dictionary.  This is used to lookup field
parameters that are not specified in the control methods.
 
parms:
   fields::
      [dict<string, @FieldInfo>]  Dictionary mapping field names
      to field information objects.

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class FormButton(FormControl)
    
Method resolution order:
FormButton
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
setLabel(self, label)

Methods inherited from web.htmlo.HTMLElement:
__init__(self, *parms, **kw)
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class FormControl(web.htmlo.XNull)
    
Method resolution order:
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods inherited from web.htmlo.HTMLElement:
__init__(self, *parms, **kw)
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class FormGroup(FormControl)
    This elemlet is a layout object that corresponds to a group of
controls.
 
 
Method resolution order:
FormGroup
FormControl
web.htmlo.XNull
web.htmlo.HTMLElement
web.xmlo.Element

Methods defined here:
__init__(self, request, *parms)
addChoice(self, name, label=None, options=[], value=None)
Adds a new "choice" control to the form.
 
parms:
   name::
      [string] choice control name.
   label::
      [string or None] label associated with the choice
   options::
      [list<string>] list of options
   value::
      [string or None] selected item in the list of options.
addControl(self, control)
Adds a form control to the group.
 
Muet be implemented by derived class.
 
parms:
   control::
      [@FormControl] control to be added.
addEntry(self, name, width=None, label=None, required=1, secret=0)
Adds an entry control to the group.  The entry control is obtained
from the "form.entry.required" or "form.entry.optional" method,
depending on whether the entry is required or optional.
 
parms:
   name::
      [string] entry name.  This is the name by which the entry
      control will be accessed.
   width::
      [int or None] if not *None*, this is the field width.
   label::
      [string or None] if specified, this is the entry field label.
   required::
      [boolean] if true, this entry is a required field, and will
      be annotated as such.
   secret::
      [boolean] if true, the entry is a "password" entry (input
      is obscured).
addGroup(self, style='form')
Adds a new "control group".  This can be used to group a set of
controls together.  The new group object is returned.
 
The new group object is obtained from the "form.group./style/"
property if defined, then the "form.group" property, and
finally @DefaultFormGroup is used by default.
 
parms::
   style::
      [string] group display style.  Generally accepted styles
      are:
      
         form::
            Outer form.
         buttons::
            button panel.
      
      Other styles may be defined for richer forms.
addResetButton(self, label=None)
Adds a reset button to the group.  The reset button is obtained
from the "form.reset" property, a @DefaultResetButton instance
is used by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be
      placed on the button.  This can also be obtained from the
      value of the "form.reset.label" property, and "Reset" is
      used by default.
addSubmitButton(self, label=None)
Adds a submit button to the group.  The submmit button is obtained
from the "form.submit" property, a @DefaultSubmitButton instance
by default.
 
parms:
   label::
      [string or None] if not *None*, this is the label to be placed
      on the button.  This can also be obtained from the value
      of the "form.submit.label" property, and "Done" is used
      by default.
setFields(self, fields)
Sets the "fields" dictionary.  This is used to lookup field
parameters that are not specified in the control methods.
 
parms:
   fields::
      [dict<string, @FieldInfo>]  Dictionary mapping field names
      to field information objects.

Methods inherited from web.htmlo.HTMLElement:
formatTo(self, output, indentContent=0, indent=2, xhtml=0)
Overrides @spug.web.xml.Element.formatTo() to provide an XHTML 
parameter.
 
parms:
   output::
      [file.write] output stream
   indentContent::
      [boolean] if true, multiline content is indented.
   indent::
      [int] number of characters to indent children
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.
populate(self, valueDict)
Populates this element and all nested elements from the value
dictionary.
 
If there is a key in valueDict matching a "name" attribute in this
element, sets the value of the element in a manner appropriate to the
element type.
 
This method is intended to allow you to populate an entire form from
the values in a query dictionary.
 
The value of the element is set using the @set() method.  This
is what is generally overriden to vary the way control values are
defined.
set(self, value)
Sets the value of an element in the manner prescribed for the
element.  This is really only relevant for form controls.  The base
class version of this just sets the "value" attribute.  Derived
classes should override as appropriate.
writeTo(self, output, xhtml=0)
Overrides @spug.web.xml.Element.writeTo() to provide an XHTML
parameter.
 
parms:
   output::
      [file.write]
   xhtml::
      [boolean] if true, node and contents will be written in
      XHTML instead of normal HTML.

Methods inherited from web.xmlo.Element:
__delitem__(self, accessor)
__getitem__(self, accessor)
Gets the specified attribute or content item, depending on whether
/accessor/ is a string (or tuple) or integer.
 
parms:
   accessor::
      [string or tuple<string, string> or int] If this is a string
      or tuple, returns the associated attribute.  If it is an 
      integer, returns the associated content item.
      
      If this is a single string, returns the value of an attribute
      in the global namespace.  If it is a tuple of two strings,
      the first string is a namespace URI.
      
      If this is an integer, returns the value of a child element.
      Interspersed text is ignored.
__len__(self)
Returns the number of content nodes in the element.
__nonzero__(self)
Because we define "len", we have to define this to always return
true so that all instances of @Element are considered "true".
__setitem__(self, accessor, value)
append(self, val)
Appends a new element or text string to the contents of the element.
 
parms:
   val::
      [string or @Element]
copy(self)
Returns a deep copy of the element.
deleteItem(self, index)
Deletes the item at the specified index from the contents.
The more "correct" way to do this is through `__delitem__`:
i.e. "#del node[index]#".  However, in Python 2.2.3, doing this
to a proxy (as return from the @getParent() method) causes
a *SystemError* due to a bug in the weak reference code.
get(self, attr, default=None)
getActualNamespace(self)
Returns the actual namespace of the element name.  The "actual
namespace" is the specified namespace if there is one, 
it is the default namespace if there was no specified namespace.
getAllChildren(self)
Returns all child elements (list<@Element>).  This actually returns
a reference to an internal list, so the caller should not modify
the value returned.
getChild(self, namespace, name)
Returns the first child with the given name.  Returns None if no
such child exists.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [string]
getChildren(self, namespace, name)
Returns all children with the given name.
 
parms:
   namespace::
      [string] namespace URI
   name::
      [name]
getDefaultNamespace(self)
Returns the default namespace URI for the node (string or None,
None means that the default namespace is the global namespace).
getFullName(self)
Returns the namespace and name of the of the element 
(tuple<string, string>).  Note that the namespace is the 
/specified namespace/, not the /actual namespace/.
getName(self)
Returns the simple unqualified name of the element.
getNamespace(self, prefix)
Returns the namespace URI for the given prefix.  Returns None
if no such prefix is defined.
 
parms:
   prefix::
      [string] namespace prefix
getParent(self)
Returns the parent object (actually, a proxy to the parent object), 
*None* if there is no parent.
getPrefix(self, uri)
Returns the namespace prefix for the given URI.  Returns
None if no prefix is found for this URI.
 
parms:
   uri::
      [string] namespace URI to find the prefix for
getValue(self)
Returns the value of the element as one big string.  This will
raise a ValueError if the element contains nested child elements.
hasChildren(self)
Returns true if the element has child elements.
hasContents(self)
Returns true if the element has contents (children or character
data).
has_key(self, attr)
Returns true if the element has the given attribute.
 
parms:
   attr::
      [string or tuple<string, string>] attribute to check for.
index(self, item)
Returns the index of the item within the contents list (an integer).
 
parms:
   item::
      [string or @Element]
insert(self, index, val)
iterate(self, explorer)
Selectively iterates over the tree using the given explorer in 
a depth-first traversal.
 
parms:
   explorer::
      [callable<any>] This object will be called for the node.
      The value it returns indicates how the iteration proceeds.
      The following return values are allowed:
      
         EXPAND::
            Iterate over the children of the node.
         CONTINUE::
            Do not iterate over the children of the node, continue
            iteration with the next node in the parent's child list.
         ABORT::
            Abort iteration.
setName = __setName(self, name)
Sets the full name of the element.
 
parms:
   name::
      [tuple<string, string> or string] Either an unqualified name or
      a tuple of namespace URI and local name.
setValue = __setValue(self, newValue)
Deletes all current contens of the element, and replaces it with
the new value.
 
parms:
   newValue::
      [string]
setdefault(self, attr, default)
strip(self, stripContent=0)
Strips all "unnecessary" whitespace from the element and all nested
elements.  Unncessary whitespace is whitespace between child
elements - when using XML for structured data representation, 
this is usually just for formatting.
 
parms:
   stripContent::
      [boolean] if true, indicates that indentation of content
      elements (nodes with no nested children
stripEmptyContents(self)
If the element contents consists of nothing but whitespace, deletes
all contents.  Otherwise makes no changes to the element.
 
Returns true if contents were removed, false if not.
 
This can used to "clean out" whitespace content after removing a
child element.

Data and other attributes inherited from web.xmlo.Element:
ABORT = 3
CONTINUE = 2
EXPAND = 1

 
class FormModel
    Base class for Form "model objects" - these are objects that define
the data processing aspects of the form without any page 
emission/rendering code.
 
Derived classes should provide a "fields" class variable associated
with a dict<string, @FieldInfo> mapping field names to field 
information.
 
  Methods defined here:
getFields(self, request)
Returns the set of fields for the form.  The "fields" instance
variable is returned by default.
 
Must be implemented by derived classes.
 
parms:
   request::
      [@spug.web.wof.Request]
submit(self, request)
Called when a form is submitted.  All data processing should be
done here.  This method must return an instance of @SubmissionResult.
 
Must be implemented by derived classes.
 
parms:
   request::
      [@spug.web.wof.Request]
validate(self, request, errorList)
Used to validate form submissions.  This is called prior to 
@submit().  If it returns false, there was at least
one validation error and @emitErrorPage() will be called instead.
 
This method iterates over the field set (as defined by the
/fields/ instance variable) and calls the @FieldInfo.validate()
method for each field in it.
 
May be overriden by derived classes, if so, you probably want
to call this method first.
 
parms:
   request::
      [@spugweb.Request] the initial request object
   errorList::
      [list<string or @spug.web.htmlo.HTMLElement>] This is an
      output parameter: an empty list should be passed in.
      If there are validation errors, they will be added to this
      list.

 
class FormNode(web.wof.Node)
    Provides a nice framework for providing form processing.
 
There are two ways to work with this node, you can either create a
model object and specify it as the "form.model" property (thereby
allowing maximum flexibility in the separation of rendering and
business practice) or derive from this class and implement @submit()
(and optionally @validate()).
 
In any case, derived classes must override @emitSubmissionPage() and
@emitFormPage() to implement form submission and generation.
 
When these nodes are invoked with a remaining path of "submit",
the form submission routine is called.  When invoked with any
other remaining path, the form display routine is called.
 
Instances of derived classes should have a "fields" variable which
should be a dictionary implementation mapping field names
to @FieldInfo instances defining the field information.
 
Properties:
   form.model::
      [@FormModel] model object for the form.
 
  Methods defined here:
delegateSubmissionPage(self, request, response, actionsCompleted)
Delegates emission of the submission page to the URL specified
in the #`_lastPage`# query parm (if any).  Returns true if the
request was successfully delegated.
 
parms:
   request::
      [@wof.Request]
   response::
      [@wof.Response]
   actionsCompleted::
      [list<@htmlo.Element or string>] list of actions to pass on
      to the delegate page through the "form.actionsCompleted"
      local request key.
emitErrorPage(self, request, response, errorList)
Generates an error page suitable for displaying the validation
errors for the form.  Creates the page from an unordered list 
of validation errors followed by the return value of
@getFormElem() wrapped in the value of the "form.wrapper"
property.
 
May be overriden by derived classes: if not, @getFormElem() must
be overriden.
emitFormPage(self, request, response)
Generates the form.  Creates the page from the return value
of @getFormElem() wrapped in the value of the "wrapper"
property.
 
May be overriden by derived classes: if not, @getFormElem() must
be overriden.
emitPage(self, request, response)
emitSimpleSubmissionPage(self, request, response, actionsCompleted)
Utility method which can be used to display a simple message
acknowledging the submission of a form for pages that don't really
have anything to display and no "_lastPage" field as been passed.
 
parms:
   request::
      [@wof.Request]
   response::
      [@wof.Response]
   actionsCompleted::
      [list<string or @htmlo.Element>] list of actions completed
      for display.
emitSubmissionPage(self, request, response, submitResult)
Processes form parameters and generates response page.  Default
version of this method calls @delegateSubmissionPage() to
attempt to delegate processing, and just displays "Request 
Submitted" if the request was not delegated.
 
May be overriden by derived class.
 
parms:
   request::
      [@wof.Request]
   response::
      [@wof.Response]
   submitResult::
      [@SubmissionResult] value returned from the @FormModel.submit()
      method.
getCompleteFormElem(self, request)
Utility method which returns the form element (result of
@getFormElem()) and adds the "method" and "action" (submit path)
attributes to the form (and the `_lastPage` hidden input field,
if there is a `_lastPage` attribute).
 
Compound pages wishing to include a form should use this instead of
calling @getFormElem() directly.
 
parms:
   request::
      [@Request]
getContentType(self, request)
getFields(self, request)
See @FormModel.submit() for docs.
 
Derived classes not defining their own model objects may override 
this.
getFormElem(self, request)
Returns the form element - this is the top level element used to
contain the form.
 
Must be implemented by derived classes unless both @emitFormPage() and
@emitErrorPage() are implemented and this method is not used by them.
isStatic(self, request)
submit(self, request)
See @FormModel.submit() for docs.
 
Derived classes not defining their own model object may override this.
validate(self, request, errorList)
See @FormModel.validate() for docs.
 
Derived classes may override this and call the base class
version of the function.

Methods inherited from web.wof.Node:
__getitem__(self, property)
__init__(self, **properties)
__setitem__(self, property, val)
buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
Recursive function to build the cache for the node and its 
descendents.
 
parms:
   context::
      [@NodeContext] node invocation context.
   targetBaseURL::
      [string] base URL of the target location.  This will be the
      base of all absolute URLs used to refer to other static pages
      within the tree.  You need not specify the full URL: the 
      path portion (starting from the first slash after host name
      and optional port number) is normally adequate.
   dynamicBaseURL::
      [string or None] base URL of all dynamic web pages in the tree.
      This will be the base of all absolute URLs referred to by
      static pages.  If *None*, attempting to link to a dynamic
      node from a static node will cause an error.
emitPageInContext(self, request, response)
This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
fixExtension(self, request, pathName)
Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
getCachePath(self, request)
Returns the cache path for the node.  By default this is constructed
from the cache path for the node with the extension for its content
type appended.
 
May be overriden by derived classes.
getDependentsTimestamp(self, request)
Returns the timestamp of the newest dependent (float).
 
This method returns the timestamp based purely upon the timestamps
of the modules of the classes (immediate and ancestor) of the 
current page node.
 
Derived classes should override it if they have dependencies on
information that is outside of the scope of these modules, and
should call the base class form of the method to obtain
the "code timestamp" for comparison.
getNodeAtPath(self, path, parentContext=None, name='')
Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info 
(tuple<@Node, @NodeContext, string>).
 
parms:
   path::
      [string] full path
   parentContext::
      [@NodeContext] the parent's context
   name::
      [string] the name that the node was referenced under (part of
      the path)
getPage(self, request, response)
Gets the content of the page identified in the request and
writes it into the response.  If the request is for a static
page, the cache is refreshed and the response is written from the
cache.  If not, @emitPage() is called directly and is expected
to write a page of content type specified by the @getContentType()
method.
getPageInContext(self, request, response)
Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
getSourcePath(self)
Returns the node's "source path".  This is not context dependent.
has_key(self, property)
isLocalRoot(self, treeName)
Returns true if the node is the local root for the given tree name.
 
parms:
   treeName::
      [string] tree to check for.  A value of '.cur' always
      returns true.
load(self)
"Loads" the node - this causes the node object to be fully
initialized.  A node must be loaded prior to performing any other
operations on it.
 
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
 
Derived classes should not override this: override @_load() instead.
refreshCache(self, request, cachePath)
Refreshes the cached image of a cacheable node.  If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
 
parms:
   request::
      [@Request]
   cachePath::
      [string] cache file name
setLocalRoot(self, treeName)
This method defines a node as a "local root".  Local roots allow
URLs to be constructed relative to a known base.  A local root
parameter can be specified in @Request.getAbsolutePath().
 
parms:
   treeName::
      [string] tree that the node is a local root for.  Values
      beginning with '.' are reserved and _should not be used_.

 
class SubmissionResult
    Abstract base class for objects returned from the @FormModel.submit()
method.
 
  Methods defined here:
getActionsCompleted(self)
Returns a list of actions completed (list<string or @htmlo.Element>)
identifying the actions completed by the form.
getErrors(self)
Returns all of the errors as a list of strings or @FieldError
instances (list<string or @FieldError>).  Returns *None* if
no errors occurred.
 
Must be implemented by derived class.
getResult(self)
Returns the result object (which can be of any type).
The caller should first have checked for errors with @getErrors().
 
Must be implemented by derived class.

 
class TestNode(FormNode)
    
Method resolution order:
TestNode
FormNode
web.wof.Node

Methods defined here:
emitSubmissionPage(self, request, response, submitResult)
getFormElem(self, request)

Data and other attributes defined here:
fields = {'email': <web.form.FieldInfo instance at 0x824dc4c>, 'name': <web.form.FieldInfo instance at 0x824d9ec>}

Methods inherited from FormNode:
delegateSubmissionPage(self, request, response, actionsCompleted)
Delegates emission of the submission page to the URL specified
in the #`_lastPage`# query parm (if any).  Returns true if the
request was successfully delegated.
 
parms:
   request::
      [@wof.Request]
   response::
      [@wof.Response]
   actionsCompleted::
      [list<@htmlo.Element or string>] list of actions to pass on
      to the delegate page through the "form.actionsCompleted"
      local request key.
emitErrorPage(self, request, response, errorList)
Generates an error page suitable for displaying the validation
errors for the form.  Creates the page from an unordered list 
of validation errors followed by the return value of
@getFormElem() wrapped in the value of the "form.wrapper"
property.
 
May be overriden by derived classes: if not, @getFormElem() must
be overriden.
emitFormPage(self, request, response)
Generates the form.  Creates the page from the return value
of @getFormElem() wrapped in the value of the "wrapper"
property.
 
May be overriden by derived classes: if not, @getFormElem() must
be overriden.
emitPage(self, request, response)
emitSimpleSubmissionPage(self, request, response, actionsCompleted)
Utility method which can be used to display a simple message
acknowledging the submission of a form for pages that don't really
have anything to display and no "_lastPage" field as been passed.
 
parms:
   request::
      [@wof.Request]
   response::
      [@wof.Response]
   actionsCompleted::
      [list<string or @htmlo.Element>] list of actions completed
      for display.
getCompleteFormElem(self, request)
Utility method which returns the form element (result of
@getFormElem()) and adds the "method" and "action" (submit path)
attributes to the form (and the `_lastPage` hidden input field,
if there is a `_lastPage` attribute).
 
Compound pages wishing to include a form should use this instead of
calling @getFormElem() directly.
 
parms:
   request::
      [@Request]
getContentType(self, request)
getFields(self, request)
See @FormModel.submit() for docs.
 
Derived classes not defining their own model objects may override 
this.
isStatic(self, request)
submit(self, request)
See @FormModel.submit() for docs.
 
Derived classes not defining their own model object may override this.
validate(self, request, errorList)
See @FormModel.validate() for docs.
 
Derived classes may override this and call the base class
version of the function.

Methods inherited from web.wof.Node:
__getitem__(self, property)
__init__(self, **properties)
__setitem__(self, property, val)
buildCache(self, context, targetBaseURL, dynamicBaseURL=None)
Recursive function to build the cache for the node and its 
descendents.
 
parms:
   context::
      [@NodeContext] node invocation context.
   targetBaseURL::
      [string] base URL of the target location.  This will be the
      base of all absolute URLs used to refer to other static pages
      within the tree.  You need not specify the full URL: the 
      path portion (starting from the first slash after host name
      and optional port number) is normally adequate.
   dynamicBaseURL::
      [string or None] base URL of all dynamic web pages in the tree.
      This will be the base of all absolute URLs referred to by
      static pages.  If *None*, attempting to link to a dynamic
      node from a static node will cause an error.
emitPageInContext(self, request, response)
This is a special purpose function to allow page delegation.
Emits the page in its "native execution context".
fixExtension(self, request, pathName)
Fixes the extension of /pathName/ so that it corresponds to the
content type of the node.
getCachePath(self, request)
Returns the cache path for the node.  By default this is constructed
from the cache path for the node with the extension for its content
type appended.
 
May be overriden by derived classes.
getDependentsTimestamp(self, request)
Returns the timestamp of the newest dependent (float).
 
This method returns the timestamp based purely upon the timestamps
of the modules of the classes (immediate and ancestor) of the 
current page node.
 
Derived classes should override it if they have dependencies on
information that is outside of the scope of these modules, and
should call the base class form of the method to obtain
the "code timestamp" for comparison.
getNodeAtPath(self, path, parentContext=None, name='')
Returns a tuple consisting of the node dereferenced by the given
path, the node context and the remainder of the path info 
(tuple<@Node, @NodeContext, string>).
 
parms:
   path::
      [string] full path
   parentContext::
      [@NodeContext] the parent's context
   name::
      [string] the name that the node was referenced under (part of
      the path)
getPage(self, request, response)
Gets the content of the page identified in the request and
writes it into the response.  If the request is for a static
page, the cache is refreshed and the response is written from the
cache.  If not, @emitPage() is called directly and is expected
to write a page of content type specified by the @getContentType()
method.
getPageInContext(self, request, response)
Gets the page in its "native execution context" (for now, just
the current working directory, but eventually this could have
more meaning than that).
getSourcePath(self)
Returns the node's "source path".  This is not context dependent.
has_key(self, property)
isLocalRoot(self, treeName)
Returns true if the node is the local root for the given tree name.
 
parms:
   treeName::
      [string] tree to check for.  A value of '.cur' always
      returns true.
load(self)
"Loads" the node - this causes the node object to be fully
initialized.  A node must be loaded prior to performing any other
operations on it.
 
Loading is disassociated from intialization so that we don't have
to build the entire node tree during initialization.
 
Derived classes should not override this: override @_load() instead.
refreshCache(self, request, cachePath)
Refreshes the cached image of a cacheable node.  If the node is out
of date with its dependents (@getDependentsTimestamp() should
return the timestamp of the newest dependent) this calls
@emitPage() with a modified request that writes to the cache file.
 
parms:
   request::
      [@Request]
   cachePath::
      [string] cache file name
setLocalRoot(self, treeName)
This method defines a node as a "local root".  Local roots allow
URLs to be constructed relative to a known base.  A local root
parameter can be specified in @Request.getAbsolutePath().
 
parms:
   treeName::
      [string] tree that the node is a local root for.  Values
      beginning with '.' are reserved and _should not be used_.

 
Functions
       
submitAdapter(unused, request, response)