[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces - form.py:1.11
Garrett Smith
garrett at mojave-corp.com
Fri Mar 5 23:17:56 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/interfaces
In directory cvs.zope.org:/tmp/cvs-serv15646/src/zope/app/interfaces
Modified Files:
form.py
Log Message:
Merged changes from garrett-widgets2-branch:
- Changed the way widgets are looked up to use interfaces instead of
names.
- Refactor of zope/app/form/utility.py -- see
http://dev.zope.org/Zope3/WidgetsAndMultiwayAdapters
for details.
- Moved configuration of vocab widgets to its own zcml file
(zope/app/browser/form/vocabularywidget.zcml).
- Removed 'propertyNames' and 'getValue' from widgets. This is replaced
by accessing the widget attributes directly.
- Deleted depreated methods from widget interface: haveData and getData.
=== Zope3/src/zope/app/interfaces/form.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/interfaces/form.py:1.10 Tue Feb 24 09:19:07 2004
+++ Zope3/src/zope/app/interfaces/form.py Fri Mar 5 23:17:25 2004
@@ -54,7 +54,7 @@
class ErrorContainer(Exception):
- """A base error class for collecting multiple errors
+ """A base error class for collecting multiple errors.
"""
def append(self, error):
@@ -79,23 +79,57 @@
class WidgetsError(ErrorContainer):
"""A collection of errors from widget processing.
+
+ widgetValues is a map containing the list of values that were obtained
+ from the widget, keyed by field name.
"""
+
+ def __init__(self, errors, widgetsData={}):
+ Exception.__init__(self, *errors)
+ self.widgetsData = widgetsData
class IWidget(IView):
"""Generically describes the behavior of a widget.
- The widget defines a list of propertyNames, which describes
- what properties of the widget are available to use for
- constructing the widget render output.
-
Note that this level must be still presentation independent.
"""
- propertyNames = Attribute("""This is a list of attributes that are
- defined for the widget.""")
+ name = Attribute(
+ """The uniquewidget name
+
+ This must be unique within a set of widgets.""")
- def getValue(name):
- """Look up a Widget configuration setting by name."""
+ title = Attribute(
+ """The widget title.
+
+ Title may be translated for the request.""")
+
+ description = Attribute(
+ """The widget description.
+
+ Description may be translated for the request.""")
+
+ visible = Attribute(
+ """A flag indicating whether or not the widget is visible.""")
+
+ def setRenderedValue(value):
+ """Set the value to be rendered by the widget.
+
+ Calling this method will override any values provided by the user.
+ """
+
+ def setPrefix(prefix):
+ """Set the name prefix used for the widget
+
+ The widget name is used to identify the widget's data within
+ input data. For example, for HTTP forms, the widget name is
+ used for the form key.
+ """
+
+class IInputWidget(IWidget):
+ """A widget for editing a field value."""
+
+ required = Attribute("Flag indicating whether the field is required")
def validate():
"""Validate the widget data.
@@ -125,7 +159,6 @@
See validate() for validation performed.
"""
-
def hasInput():
"""Returns True if the widget has input.
@@ -149,29 +182,5 @@
based on the field constraints.
"""
- name = Attribute("""The uniquewidget name
-
- This must be unique within a set of widgets.
- """)
-
- title = Attribute(
- """The widget title; may be translated for the request""")
-
- description = Attribute(
- """The widget description; may be translated for the request""")
-
- required = Attribute("Flag indicating whether the field is required")
-
- def setRenderedValue(value):
- """Set the value to be rendered by the widget.
-
- Calling this method will override any values provided by the user.
- """
-
- def setPrefix(prefix):
- """Set the name prefix used for the widget
-
- The widget name is used to identify the widget's data within
- input data. For example, for HTTP forms, the widget name is
- used for the form key.
- """
+class IDisplayWidget(IWidget):
+ """A widget for displaying a field value."""
More information about the Zope3-Checkins
mailing list