[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/form/ Update doc
strings to ReST
Phil Ruggera
pruggera at san.rr.com
Sat Jul 24 01:51:58 EDT 2004
Log message for revision 26748:
Update doc strings to ReST
Changed:
U Zope3/trunk/src/zope/app/form/__init__.py
U Zope3/trunk/src/zope/app/form/browser/__init__.py
U Zope3/trunk/src/zope/app/form/browser/add.py
U Zope3/trunk/src/zope/app/form/browser/addwizard.py
U Zope3/trunk/src/zope/app/form/browser/boolwidgets.py
U Zope3/trunk/src/zope/app/form/browser/complexsample/complexsample.py
U Zope3/trunk/src/zope/app/form/browser/complexsample/interfaces.py
U Zope3/trunk/src/zope/app/form/browser/complexsample/vocabulary.py
U Zope3/trunk/src/zope/app/form/browser/complexsample/widgetapi.py
U Zope3/trunk/src/zope/app/form/browser/editview.py
U Zope3/trunk/src/zope/app/form/browser/editwizard.py
U Zope3/trunk/src/zope/app/form/browser/exception.py
U Zope3/trunk/src/zope/app/form/browser/interfaces.py
U Zope3/trunk/src/zope/app/form/browser/itemswidgets.py
U Zope3/trunk/src/zope/app/form/browser/macros.py
U Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/form/browser/metadirectives.py
U Zope3/trunk/src/zope/app/form/browser/objectwidget.py
U Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
U Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
U Zope3/trunk/src/zope/app/form/browser/submit.py
U Zope3/trunk/src/zope/app/form/browser/textwidgets.py
U Zope3/trunk/src/zope/app/form/browser/vocabularyquery.py
U Zope3/trunk/src/zope/app/form/browser/widget.py
U Zope3/trunk/src/zope/app/form/interfaces.py
U Zope3/trunk/src/zope/app/form/utility.py
-=-
Modified: Zope3/trunk/src/zope/app/form/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/form/__init__.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/__init__.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.app.form.interfaces import IWidget, InputErrors
from zope.component.interfaces import IViewFactory
from zope.interface import implements
@@ -46,10 +48,10 @@
return translate(text, "zope", context=self.request, default=text)
def _renderedValueSet(self):
- """Returns True if the the widget's rendered value has been set.
+ """Returns ``True`` if the the widget's rendered value has been set.
This is a convenience method that widgets can use to check whether
- or not setRenderedValue was called.
+ or not `setRenderedValue` was called.
"""
return self._data is not self._data_marker
Modified: Zope3/trunk/src/zope/app/form/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/__init__.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/__init__.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.app.form.browser.widget import BrowserWidget, DisplayWidget
from zope.app.form.browser.textwidgets import TextWidget, BytesWidget
Modified: Zope3/trunk/src/zope/app/form/browser/add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/add.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/add.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
import sys
from zope.app import zapi
Modified: Zope3/trunk/src/zope/app/form/browser/addwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/addwizard.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/addwizard.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
import sys
from zope.app import zapi
@@ -32,7 +34,7 @@
class AddWizardView(EditWizardView):
"""Multi-page add-view base class.
- Subclasses should provide a schema attribute defining the schema
+ Subclasses should provide a `schema` attribute defining the schema
to be edited.
"""
@@ -54,9 +56,9 @@
The data argument is a dictionary with the data entered in the form.
- Issues a redirect to context.nextURL()
+ Issues a redirect to `context.nextURL()`
- Returns False, as per editview.apply_update
+ Returns ``False``, as per `editview.apply_update`
"""
# This code originally from add.py's createAndAdd method
Modified: Zope3/trunk/src/zope/app/form/browser/boolwidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/boolwidgets.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/boolwidgets.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.interface import implements
from zope.schema.vocabulary import SimpleVocabulary
@@ -28,7 +30,7 @@
"""A checkbox widget used to display Bool fields.
For more detailed documentation, including sample code, see
- tests/test_checkboxwidget.py.
+ ``tests/test_checkboxwidget.py``.
"""
type = 'checkbox'
default = 0
@@ -71,13 +73,13 @@
super(CheckBoxWidget, self).hasInput()
def _getFormInput(self):
- """Returns the form input used by _toFieldValue.
+ """Returns the form input used by `_toFieldValue`.
Return values:
- 'on' checkbox is checked
- '' checkbox is not checked
- None form input was not provided
+ ``'on'`` checkbox is checked
+ ``''`` checkbox is not checked
+ ``None`` form input was not provided
"""
if self.request.get(self.name) == 'on':
Modified: Zope3/trunk/src/zope/app/form/browser/complexsample/complexsample.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/complexsample/complexsample.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/complexsample/complexsample.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from xml.sax.saxutils import escape, quoteattr
from zope.app.form.browser.complexsample import widgetapi
Modified: Zope3/trunk/src/zope/app/form/browser/complexsample/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/complexsample/interfaces.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/complexsample/interfaces.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.schema import BytesLine
from zope.schema.interfaces import IVocabularyQuery
from zope.schema.interfaces import IVocabularyTokenized, IBaseVocabulary
@@ -24,7 +26,7 @@
class ITitledTokenizedTerm(ITokenizedTerm):
- """ITokenizedTerm that also has a title attribute."""
+ """`ITokenizedTerm` that also has a title attribute."""
title = BytesLine(title=_(u"Title"))
Modified: Zope3/trunk/src/zope/app/form/browser/complexsample/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/complexsample/vocabulary.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/complexsample/vocabulary.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.interface.declarations import implements
from zope.schema.interfaces import ITokenizedTerm, IIterableVocabulary
Modified: Zope3/trunk/src/zope/app/form/browser/complexsample/widgetapi.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/complexsample/widgetapi.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/complexsample/widgetapi.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -11,13 +11,15 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Alternate base classes for IBrowserWidget implementations.
+"""Alternate base classes for `IBrowserWidget` implementations.
-The base classes provided here implement the IBrowserWidget API and
+The base classes provided here implement the `IBrowserWidget` API and
provide a simpler API that derived classes are expected to implement.
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from xml.sax.saxutils import escape, quoteattr
from zope.interface import implements
@@ -140,10 +142,10 @@
This method should not load values from the request.
- Derived classes should call the base class initialize() before
+ Derived classes should call the base class `initialize()` before
performing specialized initialization. This requirement is
waived for classes which inherit directly from, and *only*
- from, BaseWidget.
+ from, `BaseWidget`.
"""
def label(self):
@@ -153,11 +155,11 @@
def loadValueFromRequest(self):
"""Load the value from data in the request."""
raise NotImplementedError(
- "BaseWidget subclasses must implement loadValueFromRequest()")
+ "BaseWidget subclasses must implement `loadValueFromRequest()`")
def render(self, value):
raise NotImplementedError(
- "BaseWidget subclasses must implement render()")
+ "BaseWidget subclasses must implement `render()`")
class BaseVocabularyWidget(BaseWidget):
@@ -201,8 +203,8 @@
def loadValueFromRequest(self):
"""Load the value from data in the request.
- If self.queryview is not None, this method is responsible for
- calling the query view's performAction() method with the value
+ If `self.queryview` is not ``None``, this method is responsible for
+ calling the query view's `performAction()` method with the value
loaded, and returning the result::
value = ...load value from request data...
@@ -217,7 +219,7 @@
def convertTokensToValues(self, tokens):
"""Convert a list of tokens to a list of values.
- If an invalid token is encountered, WidgetInputError is raised.
+ If an invalid token is encountered, `WidgetInputError` is raised.
"""
L = []
for token in tokens:
@@ -319,7 +321,7 @@
def initialize(self):
"""Initialization which does not require reading the request.
- Derived classes should call the base class initialize() before
+ Derived classes should call the base class `initialize()` before
performing specialized initialization.
"""
# Should loading from the request happen here?
@@ -351,25 +353,25 @@
# Methods which must be overriden by subclasses:
def getResults(self):
- """Perform the query, or return None.
+ """Perform the query, or return ``None``.
- The return value should be None if there is no query to
+ The return value should be ``None` if there is no query to
execute, or an object that can be rendered as a set of results
- by renderQueryResults().
+ by `renderQueryResults()`.
If the query results in an empty set of results, some value
- other than None should be used to represent the results so
- that renderQueryResults() can provide a helpful message.
+ other than ``None`` should be used to represent the results so
+ that `renderQueryResults()` can provide a helpful message.
"""
raise NotImplementedError(
- "BaseQueryView subclasses must implement getResults()")
+ "`BaseQueryView` subclasses must implement `getResults()`")
def renderInput(self):
"""Render the input area of the query view."""
raise NotImplementedError(
- "BaseQueryView subclasses must implement renderInput()")
+ "`BaseQueryView` subclasses must implement `renderInput()`")
def renderQueryResults(self, results, value):
- """Render the results returned by getResults()."""
+ """Render the results returned by `getResults()`."""
raise NotImplementedError(
- "BaseQueryView subclasses must implement renderQueryResults()")
+ "`BaseQueryView` subclasses must implement `renderQueryResults()`")
Modified: Zope3/trunk/src/zope/app/form/browser/editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editview.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/editview.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from datetime import datetime
from transaction import get_transaction
@@ -42,11 +44,12 @@
class EditView(BrowserView):
"""Simple edit-view base class
- Subclasses should provide a schema attribute defining the schema
+ Subclasses should provide a `schema` attribute defining the schema
to be edited.
The automatically generated widgets are available by name through
- the attributes *_widget. (E.g. view.title_widget for the title widget)
+ the attributes `*_widget`.
+ (E.g. ``view.title_widget for the title widget``)
"""
errors = ()
Modified: Zope3/trunk/src/zope/app/form/browser/editwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editwizard.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/editwizard.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,7 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.security.checker import defineChecker, NamesChecker
Modified: Zope3/trunk/src/zope/app/form/browser/exception.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/exception.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/exception.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from cgi import escape
from zope.interface import implements
Modified: Zope3/trunk/src/zope/app/form/browser/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/interfaces.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/interfaces.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.interface import Interface
from zope.schema import TextLine, Bool
from zope.app.form.interfaces import IWidget, IInputWidget
@@ -80,14 +82,14 @@
Form input elements should be included, prefixed with the
prefix given to setPrefix.
- 'form' and 'submit' elements should not be included. They
+ `form` and `submit` elements should not be included. They
will be provided for the larger form.
"""
def setPrefix(prefix):
- """Set the prefix used for names of input elements
+ """Set the `prefix` used for names of input elements
- Element names should begin with the given prefix,
+ Element names should begin with the given `prefix`,
followed by a dot.
"""
@@ -101,9 +103,9 @@
Classes supplied when defining add forms may need to override some
of these methods.
- In particular, when the context of an add form is not an IAdding,
- a subclass needs to override ``nextURL`` and one of ``add`` or
- ``createAndAdd``.
+ In particular, when the context of an add form is not an `IAdding`,
+ a subclass needs to override `nextURL` and one of `add` or
+ `createAndAdd`.
To see how all this fits together, here's pseudo code for the
update() method of the form:
@@ -125,7 +127,7 @@
The data argument is a dictionary with values supplied by the form.
If any user errors occur, they should be collected into a list
- and raised as a WidgetsError.
+ and raised as a ``WidgetsError``.
(For the default implementation, see pseudo-code in class docs.)
"""
@@ -134,11 +136,11 @@
"""Add the given content.
This method is overridden when the context of the add form is
- not an IAdding. In this case, the class that customizes the
+ not an `IAdding`. In this case, the class that customizes the
form must take over adding the object.
- The default implementation returns self.context.add(content),
- i.e. it delegates to the IAdding view.
+ The default implementation returns `self.context.add(content)`,
+ i.e. it delegates to the `IAdding` view.
"""
def nextURL():
@@ -146,11 +148,11 @@
This can be relative to the view's context.
- The default implementation returns self.context.nextURL(),
- i.e. it delegates to the IAdding view.
+ The default implementation returns `self.context.nextURL()`,
+ i.e. it delegates to the `IAdding` view.
"""
class IVocabularyQueryView(Interface):
- """View support for IVocabularyQuery objects.
+ """View support for `IVocabularyQuery` objects.
Implementations of this interface are used by vocabulary field
edit widgets to support query and result presentations.
@@ -166,8 +168,8 @@
components separated by dots may be appended if multiple form
fields are needed.
- This method will be called after the IVocabularyQueryView has
- been created and before performAction() is called.
+ This method will be called after the `IVocabularyQueryView` has
+ been created and before `performAction()` is called.
"""
@@ -177,23 +179,23 @@
This allows the query view to take advantage of rendering
helper methods made available by the widget.
- This method will be called after the IVocabularyQueryView has
- been created and before performAction() is called.
+ This method will be called after the `IVocabularyQueryView` has
+ been created and before `performAction()` is called.
"""
def performAction(value):
"""Perform any action indicated by any submit buttons in the
sub-widget.
- 'value' is the current value of the field. Submit actions may
+ `value` is the current value of the field. Submit actions may
cause the value to be modified. If so, the new value should
be returned; otherwise the old value should be returned.
Actions should only be performed if a submit button provided
by the view was selected.
- This method will be called after setName() and setWidget() and
- before renderInput() or renderResults().
+ This method will be called after `setName()` and `setWidget()` and
+ before `renderInput()` or `renderResults()`.
"""
def renderInput():
@@ -202,7 +204,7 @@
def renderResults(value):
"""Return a rendering of the results portion of the widget.
- 'value' is the current value represented by the widget.
+ `value` is the current value represented by the widget.
"""
class IWidgetInputErrorView(Interface):
Modified: Zope3/trunk/src/zope/app/form/browser/itemswidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/itemswidgets.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/itemswidgets.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from xml.sax.saxutils import escape
from zope.interface import implements
from zope.i18n import translate
@@ -96,11 +98,11 @@
"__call__() must be implemented by a subclass; use _getFormValue()")
def textForValue(self, term):
- """Extract a string from the term.
+ """Extract a string from the `term`.
- The term must be a vocabulary tokenized term.
+ The `term` must be a vocabulary tokenized term.
- This can be overridden to support more complex term objects. The token
+ This can be overridden to support more complex `term` objects. The token
is returned here since it's the only thing known to be a string, or
str()able."""
if ITitledTokenizedTerm.providedBy(term):
@@ -162,7 +164,7 @@
self._data = value
def _toFieldValue(self, input):
- """See SimpleInputWidget"""
+ """See `SimpleInputWidget`"""
raise NotImplementedError(
"_toFieldValue(input) must be implemented by a subclass\n"
"It may be inherited from the mix-in classes SingleDataHelper\n"
@@ -375,7 +377,7 @@
def renderItemsWithValues(self, values):
"""Render the list of possible values, with those found in
- 'values' being marked as selected."""
+ `values` being marked as selected."""
cssClass = self.cssClass
@@ -405,14 +407,14 @@
return rendered_items
def renderItem(self, index, text, value, name, cssClass):
- """Render an item for a particular value."""
+ """Render an item for a particular `value`."""
return renderElement('option',
contents=escape(text),
value=value,
cssClass=cssClass)
def renderSelectedItem(self, index, text, value, name, cssClass):
- """Render an item for a particular value that is selected."""
+ """Render an item for a particular `value` that is selected."""
return renderElement('option',
contents=escape(text),
value=value,
Modified: Zope3/trunk/src/zope/app/form/browser/macros.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/macros.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/macros.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.app.basicskin.standardmacros import StandardMacros
Modified: Zope3/trunk/src/zope/app/form/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/metaconfigure.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/metaconfigure.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
import os
from zope.interface import implementedBy
Modified: Zope3/trunk/src/zope/app/form/browser/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/metadirectives.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/metadirectives.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.interface import Interface
from zope.configuration.fields import GlobalObject, Tokens, Path, \
Bool, PythonIdentifier, MessageID
@@ -218,7 +220,7 @@
Adding an object is a bit trickier than editing an object, because
the object the schema applies to isn't available when forms are
- being rendered. The addwizard directive provides an customization
+ being rendered. The addwizard directive provides a customization
interface to overcome this difficulty.
See zope.app.browser.form.interfaces.IAddFormCustomization.
@@ -294,7 +296,7 @@
Adding an object is a bit trickier than editing an object, because
the object the schema applies to isn't available when forms are
- being rendered. The addform directive provides an customization
+ being rendered. The addform directive provides a customization
interface to overcome this difficulty.
See zope.app.browser.form.interfaces.IAddFormCustomization.
Modified: Zope3/trunk/src/zope/app/form/browser/objectwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/objectwidget.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/objectwidget.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.interface import implements
from zope.schema import getFieldNamesInOrder
@@ -102,10 +104,10 @@
def getInputValue(self):
"""Return converted and validated widget data.
- The value for this field will be represented as an ObjectStorage
+ The value for this field will be represented as an `ObjectStorage`
instance which holds the subfield values as attributes. It will
need to be converted by higher-level code into some more useful
- object (note that the default EditView calls applyChanges, which
+ object (note that the default EditView calls `applyChanges`, which
does this).
"""
content = self.factory()
@@ -136,7 +138,7 @@
def hasInput(self):
"""Is there input data for the field
- Return True if there is data and False otherwise.
+ Return ``True`` if there is data and ``False`` otherwise.
"""
for name in self.names:
if self.getSubWidget(name).hasInput():
Modified: Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.app import zapi
from zope.schema import getFieldNamesInOrder
@@ -32,7 +34,7 @@
class DisplayView(BrowserView):
"""Simple display-view base class.
- Subclasses should provide a schema attribute defining the schema
+ Subclasses should provide a `schema` attribute defining the schema
to be displayed.
"""
Modified: Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/sequencewidget.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/sequencewidget.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
import re
from zope.interface import implements
from zope.i18n import translate
@@ -132,12 +134,12 @@
"""Return converted and validated widget data.
If there is no user input and the field is required, then a
- MissingInputError will be raised.
+ ``MissingInputError`` will be raised.
If there is no user input and the field is not required, then
the field default value will be returned.
- A WidgetInputError is returned in the case of one or more
+ A ``WidgetInputError`` is returned in the case of one or more
errors encountered, inputting, converting, or validating the data.
"""
sequence = self._generateSequence()
@@ -159,7 +161,7 @@
def hasInput(self):
"""Is there input data for the field
- Return True if there is data and False otherwise.
+ Return ``True`` if there is data and ``False`` otherwise.
"""
return len(self._generateSequence()) != 0
Modified: Zope3/trunk/src/zope/app/form/browser/submit.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/submit.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/submit.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -17,6 +17,7 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
Next = "NEXT_SUBMIT"
Previous = "PREVIOUS_SUBMIT"
Modified: Zope3/trunk/src/zope/app/form/browser/textwidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from xml.sax import saxutils
from zope.interface import implements
@@ -73,7 +75,7 @@
value="Bob"
/>
- Calling setRenderedValue will change what gets output:
+ Calling `setRenderedValue` will change what gets output:
>>> widget.setRenderedValue("Barry")
>>> print normalize( widget() )
@@ -231,7 +233,7 @@
world!"
/>
- Calling setRenderedValue will change what gets output:
+ Calling `setRenderedValue` will change what gets output:
>>> widget.setRenderedValue("Hey\\ndude!")
>>> print normalize( widget() )
Modified: Zope3/trunk/src/zope/app/form/browser/vocabularyquery.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/vocabularyquery.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/vocabularyquery.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.interface import implements
from zope.schema.interfaces import IIterableVocabularyQuery
@@ -47,7 +49,7 @@
def getAction(self):
"""Retrieve a the executed action from the form.
- Return None, if none of the registered actions was called.
+ Return ``None``, if none of the registered actions was called.
"""
assert self.__actions is not None, \
"getAction() called on %r with no actions defined" %self
@@ -74,7 +76,7 @@
def textForValue(self, term):
"""Extract a string from the term.
- The term must be a vocabulary tokenized term.
+ The `term` must be a vocabulary tokenized term.
This can be overridden to support more complex term objects. The token
is returned here since it's the only thing known to be a string, or
@@ -113,7 +115,7 @@
self.widget = None
def setName(self, name):
- """See interfaces.IVocabularyQueryView"""
+ """See `interfaces.IVocabularyQueryView`"""
assert not name.endswith(".")
self.name = name
@@ -123,15 +125,15 @@
self.widget = widget
def performAction(self, value):
- """See interfaces.IVocabularyQueryView"""
+ """See `interfaces.IVocabularyQueryView`"""
return value
def renderInput(self):
- """See interfaces.IVocabularyQueryView"""
+ """See `interfaces.IVocabularyQueryView`"""
return self._renderQueryInput()
def renderResults(self, value):
- """See interfaces.IVocabularyQueryView"""
+ """See `interfaces.IVocabularyQueryView`"""
results = self._getResults()
if results is not None:
return self._renderQueryResults(results, value)
@@ -154,11 +156,11 @@
class IterableVocabularyQueryViewBase(VocabularyQueryViewBase):
- """Query view for IIterableVocabulary objects without more
+ """Query view for `IIterableVocabulary` objects without more
specific query views.
This should only be used (directly) for vocabularies for which
- getQuery() returns None.
+ `getQuery()` returns ``None``.
"""
queryResultBatchSize = 8
@@ -180,7 +182,7 @@
self.addAction(MORE, self._msg_more)
def setName(self, name):
- """See interfaces.IVocabularyQueryView"""
+ """See `interfaces.IVocabularyQueryView`"""
super(IterableVocabularyQueryViewBase, self).setName(name)
name = self.name
self.query_index_name = name + ".start"
@@ -272,7 +274,7 @@
"</div>"])
def performAction(self, value):
- """See interfaces.IVocabularyQueryView"""
+ """See `interfaces.IVocabularyQueryView`"""
if self.action == ADD_DONE:
value = self.addSelections(value)
self.query_index = None
Modified: Zope3/trunk/src/zope/app/form/browser/widget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/widget.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/browser/widget.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
import re, cgi
import traceback
from xml.sax.saxutils import quoteattr
@@ -40,7 +42,7 @@
The class provides some basic functionality common to all browser widgets.
- Browser widgets have a 'required' attribute, which indicates whether or
+ Browser widgets have a `required` attribute, which indicates whether or
not the underlying field requires input. By default, the widget's required
attribute is equal to the field's required attribute:
@@ -55,16 +57,16 @@
>>> widget.required
False
- However, the two 'required' values are independent of one another:
+ However, the two `required` values are independent of one another:
>>> field.required = True
>>> widget.required
False
Browser widgets have an error state, which can be rendered in a form using
- the error() method. The error method delegates the error rendering to a
- view that is registered as providing IWidgetInputErrorView. To illustrate,
- we can create and register a simple error display view:
+ the `error()` method. The error method delegates the error rendering to a
+ view that is registered as providing `IWidgetInputErrorView`. To
+ illustrate, we can create and register a simple error display view:
>>> from zope.app.form.interfaces import IWidgetInputError
>>> class SnippetErrorView:
@@ -152,7 +154,7 @@
>>> widget.error()
''
- setRenderedValue is used to specify the value displayed by the widget to
+ `setRenderedValue` is used to specify the value displayed by the widget to
the user. This value, however, is not the same as the input value, which
is read from the request:
@@ -170,7 +172,7 @@
>>> widget.name
'baz.foo'
- getInputValue always returns a value that can legally be assigned to
+ `getInputValue` always returns a value that can legally be assigned to
the widget field. To illustrate widget validation, we can add a constraint
to its field:
@@ -184,24 +186,24 @@
u'bye world'
This input violates the new field constraint and therefore causes an
- error when getInputValue is called:
+ error when `getInputValue` is called:
>>> widget.getInputValue()
Traceback (most recent call last):
WidgetInputError: ('foo', u'Foo', bye world)
Simple input widgets require that input be available in the form request.
- If input is not present, a MissingInputError is raised:
+ If input is not present, a ``MissingInputError`` is raised:
>>> del request.form[widget.name]
>>> widget.getInputValue()
Traceback (most recent call last):
MissingInputError: ('baz.foo', u'Foo', None)
- A MissingInputError indicates that input is missing from the form
+ A ``MissingInputError`` indicates that input is missing from the form
altogether. It does not indicate that the user failed to provide a value
- for a required field. The MissingInputError above was caused by the fact
- that the form does have any input for the widget:
+ for a required field. The ``MissingInputError`` above was caused by the
+ fact that the form does have any input for the widget:
>>> request.form[widget.name]
Traceback (most recent call last):
@@ -212,8 +214,8 @@
>>> request.form[widget.name] = ''
- In such a case, if the field is required, a WidgetInputError will be
- raised on a call to getInputValue:
+ In such a case, if the field is required, a ``WidgetInputError`` will be
+ raised on a call to `getInputValue`:
>>> field.required = True
>>> widget.getInputValue()
@@ -221,7 +223,7 @@
WidgetInputError: ('foo', u'Foo', )
However, if the field is not required, the empty string will be converted
- by the widget into the field's 'missing_value' and read as a legal field
+ by the widget into the field's `missing_value` and read as a legal field
value:
>>> field.required = False
@@ -270,7 +272,7 @@
def hasInput(self):
"""See IWidget.hasInput.
- Returns True if the submitted request form contains a value for
+ Returns ``True`` if the submitted request form contains a value for
the widget, otherwise returns False.
Some browser widgets may need to implement a more sophisticated test
@@ -322,7 +324,7 @@
"""Returns current form input.
The value returned must be in a format that can be used as the 'input'
- argument to _toFieldValue.
+ argument to `_toFieldValue`.
The default implementation returns the form value that corresponds to
the widget's name. Subclasses may override this method if their form
@@ -338,7 +340,7 @@
perform an appropriate conversion.
This method is used by getInputValue to perform the conversion
- of form input (provided by _getFormInput) to an appropriate field
+ of form input (provided by `_getFormInput`) to an appropriate field
value.
"""
if input == self._missing:
Modified: Zope3/trunk/src/zope/app/form/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/form/interfaces.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/interfaces.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -15,6 +15,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.schema.interfaces import ValidationError
from zope.component.interfaces import IView
from zope.interface import Attribute, Interface, implements
@@ -35,7 +37,7 @@
def __init__(self, field_name, widget_title, errors):
"""Initialize Error
- 'errors' is a ValidationError or a list of ValidationError objects
+ `errors` is a ``ValidationError`` or a list of ValidationError objects
"""
UserError.__init__(self, field_name, widget_title, errors)
self.field_name = field_name
@@ -157,12 +159,12 @@
"""Validate the widget data.
If there is no user input and the field is required, then a
- MissingInputError will be raised.
+ ``MissingInputError`` will be raised.
If there is no user input and the field is not required, then
the field default value will be returned.
- A WidgetInputError is returned in the case of one or more
+ A ``WidgetInputError`` is returned in the case of one or more
errors encountered, inputting, converting, or validating the data.
"""
@@ -170,7 +172,7 @@
"""Return value suitable for the widget's field.
The widget must return a value that can be legally assigned to
- its bound field or otherwise raise WidgetInputError.
+ its bound field or otherwise raise ``WidgetInputError``.
See validate() for validation performed.
"""
@@ -178,18 +180,18 @@
def applyChanges(content):
"""Validate the widget data and apply it to the content.
- See validate() for validation performed.
+ See `validate()` for validation performed.
"""
def hasInput():
- """Returns True if the widget has input.
+ """Returns ``True`` if the widget has input.
Input is used by the widget to calculate an 'input value', which is
a value that can be legally assigned to a field.
- Note that the widget may return True, indicating it has input, but
- still be unable to return a value from getInputValue. Use
- hasValidInput to determine whether or not getInputValue will return
+ Note that the widget may return ``True``, indicating it has input, but
+ still be unable to return a value from `getInputValue`. Use
+ `hasValidInput` to determine whether or not `getInputValue` will return
a valid value.
A widget that does not have input should generally not be used to
@@ -197,9 +199,9 @@
"""
def hasValidInput():
- """Returns True is the widget has valid input.
+ """Returns ``True`` is the widget has valid input.
- This method is similar to hasInput but it also confirms that the
+ This method is similar to `hasInput` but it also confirms that the
input provided by the user can be converted to a valid field value
based on the field constraints.
"""
Modified: Zope3/trunk/src/zope/app/form/utility.py
===================================================================
--- Zope3/trunk/src/zope/app/form/utility.py 2004-07-24 04:28:51 UTC (rev 26747)
+++ Zope3/trunk/src/zope/app/form/utility.py 2004-07-24 05:51:58 UTC (rev 26748)
@@ -32,6 +32,8 @@
$Id$
"""
+__docformat__ = 'restructuredtext'
+
from zope.schema import getFieldsInOrder
from zope.app import zapi
from zope.app.form.interfaces import IWidget
@@ -53,16 +55,16 @@
def _createWidget(context, field, viewType, request):
- """Creates a widget given a context, field, and viewType.
+ """Creates a widget given a `context`, `field`, and `viewType`.
- Uses zapi.getViewProviding to lookup a view for the field and the
+ Uses ``zapi.getViewProviding`` to lookup a view for the field and the
viewType.
"""
field = field.bind(context)
return zapi.getViewProviding(field, viewType, request)
def _widgetHasStickyValue(widget):
- """Returns True if the widget has a sticky value.
+ """Returns ``True`` if the widget has a sticky value.
A sticky value is input from the user that should not be overridden
by an object's current field value. E.g. a user may enter an invalid
@@ -76,11 +78,11 @@
ignoreStickyValues=False, context=None):
"""Sets up a single view widget.
- The widget will be an attribute of the view. If there is already
+ The widget will be an attribute of the `view`. If there is already
an attribute of the given name, it must be a widget and it will be
- initialized with the given value if not no_value.
+ initialized with the given `value` if not ``no_value``.
- If there isn't already a view attribute of the given name, then a
+ If there isn't already a `view` attribute of the given name, then a
widget will be created and assigned to the attribute.
"""
if context is None:
@@ -114,27 +116,27 @@
def setUpWidgets(view, schema, viewType, prefix=None, ignoreStickyValues=False,
initial={}, names=None, context=None):
- """Sets up widgets for the fields defined by a schema.
+ """Sets up widgets for the fields defined by a `schema`.
- view is the view that will be configured with widgets.
+ `view` is the view that will be configured with widgets.
- schema is an interface containing the fields that widgets will be
+ `schema` is an interface containing the fields that widgets will be
created for.
- prefix is a string that is prepended to the widget names in the generated
+ `prefix` is a string that is prepended to the widget names in the generated
HTML. This can be used to differentiate widgets for different schemas.
- ignoreStickyValues is a flag that, when True, will cause widget sticky
+ `ignoreStickyValues` is a flag that, when ``True``, will cause widget sticky
values to be replaced with the context field value or a value specified
in initial.
- initial is a mapping of field names to initial values.
+ `initial` is a mapping of field names to initial values.
- names is an optional iterable that provides an ordered list of field
- names to use. If names is None, the list of fields will be defined by
+ `names` is an optional iterable that provides an ordered list of field
+ names to use. If names is ``None``, the list of fields will be defined by
the schema.
- context provides an alternative context for acquisition.
+ `context` provides an alternative context for acquisition.
"""
for (name, field) in _fieldlist(names, schema):
setUpWidget(view, name, field, viewType,
@@ -147,10 +149,10 @@
ignoreStickyValues=False, names=None, context=None):
"""Sets up widgets to collect input on a view.
- See setUpWidgets for details on view, schema, prefix, ignoreStickyValues,
- names, and context.
+ See `setUpWidgets` for details on `view`, `schema`, `prefix`,
+ `ignoreStickyValues`, `names`, and `context`.
- source, if specified, is an object from which initial widget values are
+ `source`, if specified, is an object from which initial widget values are
read. If source is not specified, the view context is used as the source.
"""
_setUpFormWidgets(view, schema, source, prefix, ignoreStickyValues,
@@ -160,10 +162,10 @@
ignoreStickyValues=False, names=None, context=None):
"""Sets up widgets to display field values on a view.
- See setUpWidgets for details on view, schema, prefix, ignoreStickyValues,
- names, and context.
+ See `setUpWidgets` for details on `view`, `schema`, `prefix`,
+ `ignoreStickyValues`, `names`, and `context`.
- source, if specified, is an object from which initial widget values are
+ `source`, if specified, is an object from which initial widget values are
read. If source is not specified, the view context is used as the source.
"""
_setUpFormWidgets(view, schema, source, prefix, ignoreStickyValues,
@@ -171,7 +173,7 @@
def _setUpFormWidgets(view, schema, source, prefix, ignoreStickyValues,
names, context, displayType, inputType):
- """A helper function used by setUpDisplayWidget and setUpEditWidget."""
+ """A helper function used by `setUpDisplayWidget` and `setUpEditWidget`."""
if context is None:
context = view.context
if source is None:
@@ -189,10 +191,11 @@
ignoreStickyValues, context)
def viewHasInput(view, schema, names=None):
- """Returns True if the any of the view's widgets contain user input.
+ """Returns ``True`` if the any of the view's widgets contain user input.
- schema specifies the set of fields that correspond to the view widgets.
- names can be specified to provide a subset of these fields.
+ `schema` specifies the set of fields that correspond to the view widgets.
+
+ `names` can be specified to provide a subset of these fields.
"""
for name, field in _fieldlist(names, schema):
if getattr(view, name + '_widget').hasInput():
@@ -202,13 +205,15 @@
def applyWidgetsChanges(view, schema, target=None, names=None):
"""Updates an object with values from a view's widgets.
- view contained the widgets that perform the update. By default, the widgets
- will update the view's context. target can be specified as an alternative
- object to update.
+ `view` contained the widgets that perform the update. By default, the
+ widgets will update the view's context.
- schema contrains the values provided by the widgets.
+ `target` can be specified as an alternative object to update.
- names can be specified to update a subset of the schema constrained values.
+ `schema` contrains the values provided by the widgets.
+
+ `names` can be specified to update a subset of the schema constrained
+ values.
"""
errors = []
changed = False
@@ -228,15 +233,15 @@
return changed
def getWidgetsData(view, schema, names=None):
- """Returns user entered data for a set of schema fields.
+ """Returns user entered data for a set of `schema` fields.
The return value is a map of field names to data values.
- view is the view containing the widgets. schema is the schema that
- defines the widget fields. An optional names argument can be provided
- to specify an alternate list of field values to return. If names is
- not specified, or is None, getWidgetsData will attempt to return values
- for all of the fields in the schema.
+ `view` is the view containing the widgets. `schema` is the schema that
+ defines the widget fields. An optional `names` argument can be provided
+ to specify an alternate list of field values to return. If `names` is
+ not specified, or is ``None``, `getWidgetsData` will attempt to return
+ values for all of the fields in the schema.
A requested field value may be omitted from the result for one of two
reasons:
@@ -247,14 +252,14 @@
- The field is editable and not required but its widget does not
contain user input.
- If a field is required and its widget does not have input, getWidgetsData
+ If a field is required and its widget does not have input, `getWidgetsData`
raises an error.
A widget may raise a validation error if it cannot return a value that
satisfies its field's contraints.
Errors, if any, are collected for all fields and reraised as a single
- WidgetsError.
+ `WidgetsError`.
"""
result = {}
errors = []
More information about the Zope3-Checkins
mailing list