[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/browser - form.py:1.5.8.1
Jim Fulton
jim@zope.com
Tue, 18 Mar 2003 11:56:16 -0500
Update of /cvs-repository/Zope3/src/zope/app/interfaces/browser
In directory cvs.zope.org:/tmp/cvs-serv21811/zope/app/interfaces/browser
Modified Files:
Tag: local-utility-branch
form.py
Log Message:
checkpoint into branch
=== Zope3/src/zope/app/interfaces/browser/form.py 1.5 => 1.5.8.1 ===
--- Zope3/src/zope/app/interfaces/browser/form.py:1.5 Thu Jan 16 14:53:09 2003
+++ Zope3/src/zope/app/interfaces/browser/form.py Tue Mar 18 11:55:46 2003
@@ -18,62 +18,48 @@
from zope.publisher.interfaces.browser import IBrowserView
from zope.app.interfaces.form import IWidget
+class IAddFormCustomization(Interface):
+ """This interface defined methods of add forms that can be overridden
-class IReadForm(IBrowserView):
- """This interface defines methods and attributes that are required to
- display a form."""
+ Classes supplied when defining add forms may need to override some
+ of these methods.
- form = Attribute(
- """The form template. Usually a Page Template.""")
-
- schema = Attribute(
- """The schema this form should be constructed from.""")
-
- custom_widgets = Attribute(
- """A dictionary that holds custom widgets for various fields.""")
-
- fields_order = Attribute(
- """A list that contains the field ids in the order they should
- be displayed. If the value of this attribute is None, then the
- fields are just grapped randomly out of the various schemas.
-
- Furthermore, if fields are specified then only these fields are
- used for the form, not all that could be possibly found.
- """)
-
- def getFields():
- """Get all the fields that need input from the content object."""
-
- def getField(name):
- """Get a field by name from the content object schemas."""
-
- def getWidgetForFieldName(name):
- """Lookup the widget of the field by name."""
-
- def getWidgetForField(field):
- """Return the correct widget instance for a field. This method
- consults the custom_widgets attribute """
-
- def renderField(field):
- """Render a field using the widgets."""
-
- def action():
- """Execute the form. By default it tries to save the values back
- into the content object."""
-
-
-class IWriteForm(IBrowserView):
- """This interface defines methods and attributes that are required to
- retrieve the data from the request and store them back into the."""
-
- def saveValuesInContext():
- """This method is responsible of retrieving all the data from
- the request, converting it, validating it and then store it back
- to the context object."""
-
-
-class IForm(IReadForm, IWriteForm):
- """This is a complete form."""
+ 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.
+ """
+
+ def nextURL():
+ """Return the URL to be displayed after the add operation
+ """
+
+ def add(content):
+ """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
+ form must take over adding the object.
+
+ The content should be returned wrapped in the context of the
+ object that it was added to.
+ """
+
+ def createAndAdd(data):
+ """Create a new object from the given data and the resulting object.
+
+ 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.
+ """
+
+ def beforeUpdateHook():
+ """Hook called just before form data is computed
+
+ Add forms can be harder to create because there is less
+ context for determining things like widget default and allowed
+ values. This hook is provided to allow forms to manipulate
+ widgets before they are used to render data or get values.
+ """
class IBrowserWidget(IWidget):