Package orm2 :: Package ui :: Package xist :: Module widgets :: Class xist_widget :: Class actual_widget
[hide private]
[frames] | no frames]

Class actual_widget

source code

widget.actual_widget --+
                       |
                      xist_widget.actual_widget
Known Subclasses:
_input.actual_widget, checkbox.actual_widget, just_display.actual_widget, mapping_radiobuttons.actual_widget, mapping_select.actual_widget

Instance Methods [hide private]
  __init__(self, dbobj, dbproperty, errors={}, name=None, title=None, help="", default=None, **kw)
@param dbobj: The dbobj whoes property is to be displayed by this widget @param errors: Dict that contains the error messages from the last commit.
  widget(self, **kw)
Returns a xist frag that represents the HTML to create the widget.
  help(self, **kw)
  label(self, **kw)
  error_message(self, error)
Return a <div class="error"> with the formated error message in it.
  row(self, plone=False, error=None, **kw)
Return a row for an HTML form <div class="row"> <div class="label">self.title</div> <div class="help">self._help if non-null</div> <div class="error">error if non-null</div> <div class="field"> self.widget() </div> </div> @param plone: Set attributes so that this form may be used with CMFPlone`s JavaScript (unimplemented) @param error: Error message to be displayed along with the widget.
  value(self)
If the current request contains a value for our form element's name, return that value, otherwise get it from the dbobj.
  get_from_request(self, use_default=False)
Check the request for a parameter with this widget's name attribute.
  set_from_request(self, use_default=False, ignore_if_unset=False)
The the dbattribute this widget is responsible for from REQUEST (using get_from_request above).
  __getattr__(self, name)
Since this class is used almost exclusively inside Zope, this will hook it into Zope's acquisition mechanism.

Method Details [hide private]

__init__(self, dbobj, dbproperty, errors={}, name=None, title=None, help="", default=None, **kw)
(Constructor)

source code 

@param dbobj: The dbobj whoes property is to be displayed by this
  widget
@param errors: Dict that contains the error messages from the last
  commit.
@param name: The name attribute of the HTML <input> (or so) element
  that will be created by this. Defaults to dbclass.attribute,
  which will do for most circumstances... A regular String.
@param title: Will overwrite the datatype.title attribute for the
  widget's caption. Unicode string required.
@param help: Help text that will be displayed along with the
  widget. May be a XIST element, of course, but you may not want
  to use block level elements in it.
@param default: Unicode String or other Python object suitable  to
  determine the default setting for this widget if dbobj is None
  (see widget() below)

The key word arguments may be used to pass arbitrary
attributes to the widget element.

Overrides: widget.actual_widget.__init__

widget(self, **kw)

source code 
Returns a xist frag that represents the HTML to create the widget. Ideally this is a single HTML element. The key word arguments will be passed as attributes, overwriting the constructor's key word arguments (see above).

help(self, **kw)

source code 
Returns:
A html.div instance containing the help message. The key word arguments will be added to the <div> as arguments. The css class defaults to 'help'

label(self, **kw)

source code 
Returns:
A html.div instance containing the widget's label (title attribute). The key word arguments will be added to the <div> as arguments. The css class defaults to 'label'

error_message(self, error)

source code 
Return a <div class="error"> with the formated error message in it.

row(self, plone=False, error=None, **kw)

source code 

Return a row for an HTML form

<div class="row">
  <div class="label">self.title</div>
  <div class="help">self._help if non-null</div>
  <div class="error">error if non-null</div>

  <div class="field">
    self.widget()
  </div>
</div>

@param plone: Set attributes so that this form may be used with
  CMFPlone`s JavaScript (unimplemented)
@param error: Error message to be displayed along with the widget.

value(self)

source code 
If the current request contains a value for our form element's name, return that value, otherwise get it from the dbobj. If that should fail, return the default.

get_from_request(self, use_default=False)

source code 
Check the request for a parameter with this widget's name attribute. It it is set return it as is. Otherwise return the default value (if use_default is True) or raise KeyError.

set_from_request(self, use_default=False, ignore_if_unset=False)

source code 
The the dbattribute this widget is responsible for from REQUEST (using get_from_request above).
Parameters:
  • REQUEST - Zope request object (or any other dict for that matter)
  • use_default - Use this widget's default value if the REQUEST does not contain an appropriate value.

__getattr__(self, name)
(Qualification operator)

source code 
Since this class is used almost exclusively inside Zope, this will hook it into Zope's acquisition mechanism.