[Zope3-checkins] SVN: Zope3/trunk/src/zope/formlib/ fix whitespace
Benji York
benji at zope.com
Wed Oct 5 16:09:33 EDT 2005
Log message for revision 38778:
fix whitespace
Changed:
U Zope3/trunk/src/zope/formlib/configure.zcml
U Zope3/trunk/src/zope/formlib/form.py
U Zope3/trunk/src/zope/formlib/form.txt
U Zope3/trunk/src/zope/formlib/interfaces.py
U Zope3/trunk/src/zope/formlib/namedtemplate.py
U Zope3/trunk/src/zope/formlib/page.py
U Zope3/trunk/src/zope/formlib/page.txt
U Zope3/trunk/src/zope/formlib/pageform.pt
U Zope3/trunk/src/zope/formlib/subpageform.pt
U Zope3/trunk/src/zope/formlib/tests.py
-=-
Modified: Zope3/trunk/src/zope/formlib/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/formlib/configure.zcml 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/configure.zcml 2005-10-05 20:09:32 UTC (rev 38778)
@@ -11,7 +11,7 @@
<adapter
for="*"
factory=".namedtemplate.NamedTemplatePathAdapter"
- name="template"
+ name="template"
/>
Modified: Zope3/trunk/src/zope/formlib/form.py
===================================================================
--- Zope3/trunk/src/zope/formlib/form.py 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/form.py 2005-10-05 20:09:32 UTC (rev 38778)
@@ -93,7 +93,7 @@
if not name:
raise ValueError(
"Field has no name")
-
+
fields.append((name, arg))
elif isinstance(arg, FormFields):
for form_field in arg:
@@ -102,8 +102,8 @@
fields.append((arg.__name__, arg))
else:
raise TypeError("Unrecognized argument type", arg)
-
+
seq = []
byname = {}
for name, field in fields:
@@ -126,7 +126,7 @@
def __len__(self):
return len(self.__FormFields_seq__)
-
+
def __iter__(self):
return iter(self.__FormFields_seq__)
@@ -140,8 +140,8 @@
if not isinstance(other, FormFields):
return NotImplemented
return self.__class__(self, other)
-
+
def select(self, *names):
"""Return a modified instance with an ordered subset of fields."""
return self.__class__(*[self[name] for name in names])
@@ -151,7 +151,7 @@
return self.__class__(*[ff for ff in self if ff.__name__ not in names])
Fields = FormFields
-
+
def fields_initkw(keep_all_readonly=False, **other):
return keep_all_readonly, other
@@ -272,12 +272,12 @@
widget.setRenderedValue(field.get(adapter))
else:
widget.setRenderedValue(field.default)
-
+
widgets.append((not readonly, widget))
return Widgets(widgets, len(form_prefix)+1)
-def setUpInputWidgets(form_fields, form_prefix, context, request,
+def setUpInputWidgets(form_fields, form_prefix, context, request,
ignore_request=False):
widgets = []
for form_field in form_fields:
@@ -310,12 +310,12 @@
if not widget.hasInput():
raise interfaces.FormError("No input", name)
-
+
try:
data[name] = widget.getInputValue()
except InputErrors, error:
errors.append(error)
-
+
return errors
def _widgetKey(widget, form_prefix):
@@ -327,7 +327,7 @@
return name
def setUpEditWidgets(form_fields, form_prefix, context, request,
- adapters=None, for_display=False,
+ adapters=None, for_display=False,
ignore_request=False):
if adapters is None:
adapters = {}
@@ -399,7 +399,7 @@
widget.setRenderedValue(data[form_field.__name__])
widgets.append((not readonly, widget))
-
+
return Widgets(widgets, len(form_prefix)+1)
@@ -413,7 +413,7 @@
- It was entered by the user, but the value entered was invalid
This exception is part of the internal implementation of checkInvariants.
-
+
"""
class FormData:
@@ -443,8 +443,8 @@
setattr(self, name, v)
return v
raise AttributeError(name)
-
+
def checkInvariants(form_fields, form_data):
# First, collect the data for the various schemas
@@ -522,11 +522,11 @@
) = _action_options(**options)
self.label = label
-
+
[self.success_handler, self.failure_handler,
self.condition, self.validator] = [
_callify(f) for f in (success, failure, condition, validator)]
-
+
if name is None:
if _identifier.match(label):
name = unicode(label).lower()
@@ -534,7 +534,7 @@
name = label.encode('hex')
self.__name__ = prefix + '.' + name
-
+
if data is None:
data = {}
self.data = data
@@ -644,7 +644,7 @@
if inst is None:
return self
return self.__class__(*[a.__get__(inst) for a in self.actions])
-
+
def handleSubmit(actions, data, default_validate=None):
for action in actions:
@@ -675,7 +675,7 @@
prefix = 'form'
status = ''
-
+
errors = ()
interface.implements(interfaces.IForm)
@@ -701,14 +701,14 @@
def resetForm(self):
self.setUpWidgets(ignore_request=True)
-
+
form_result = None
form_reset = True
def update(self):
self.setUpWidgets()
self.form_reset = False
-
+
data = {}
errors, action = handleSubmit(self.actions, data, self.validate)
self.errors = errors
@@ -722,7 +722,7 @@
else:
result = None
- self.form_result = result
+ self.form_result = result
def render(self):
# if the form has been updated, it will already have a result
@@ -746,7 +746,7 @@
yield error
else:
view = component.getMultiAdapter(
- (error, self.request),
+ (error, self.request),
zope.app.form.browser.interfaces.IWidgetInputErrorView)
title = getattr(error, 'widget_title', None) # XXX duck typing
if title:
@@ -793,14 +793,14 @@
self.status = status
else:
self.status = _('No changes')
-
+
class DisplayFormBase(FormBase):
def setUpWidgets(self, ignore_request=False):
self.adapters = {}
self.widgets = setUpEditWidgets(
self.form_fields, self.prefix, self.context, self.request,
- adapters=self.adapters, for_display=True,
+ adapters=self.adapters, for_display=True,
ignore_request=ignore_request
)
Modified: Zope3/trunk/src/zope/formlib/form.txt
===================================================================
--- Zope3/trunk/src/zope/formlib/form.txt 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/form.txt 2005-10-05 20:09:32 UTC (rev 38778)
@@ -85,7 +85,7 @@
... self.form_fields, 'form', self.context, self.request,
... ignore_request=ignore_request)
... return '\n'.join([w() for w in widgets])
-
+
Here we used form.setUpWidgets to create widget instances from our
form-field specifications. The second argument to `setUpWidgets` is a
form prefix. All of the widgets on this form are given the same
@@ -99,35 +99,35 @@
>>> print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE
<input class="textType" id="form.name" name="form.name" size="20"
type="text" value="" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="" />
If the request contains any form data, that will be reflected in the
-output:
+output:
>>> request.form['form.name'] = u'bob'
>>> print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE
<input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="" />
Sometimes we don't want this behavior: we want to ignore the request values,
particularly after a form has been processed and before it is drawn again.
-This can be accomplished with the 'ignore_request' argument in
+This can be accomplished with the 'ignore_request' argument in
setUpWidgets.
>>> print MyForm(None, request)(ignore_request=True)
... # doctest: +NORMALIZE_WHITESPACE
<input class="textType" id="form.name" name="form.name" size="20"
type="text" value="" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="" />
Reading data
@@ -156,7 +156,7 @@
... print error
... else:
... data = None
- ...
+ ...
... for w in widgets:
... print w()
... error = w.error()
@@ -172,7 +172,7 @@
- The form prefix, and
-- A data dictionary to contain input values found
+- A data dictionary to contain input values found
The keys in the data dictionary have the form prefix stripped off.
@@ -204,10 +204,10 @@
>>> request.form['form.min_size'] = u'bob'
>>> MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
There were errors:
- (u'Invalid floating point data',
+ (u'Invalid floating point data',
<exceptions.ValueError instance at ...>)
('max_size', u'Maximum size', )
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="bob" />
@@ -226,7 +226,7 @@
type="text" value="bob" />
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="142.0" />
{'max_size': 142.0,
'min_size': 42.0,
@@ -271,7 +271,7 @@
... if 'submit' in self.request:
... data = {}
... errors = form.getWidgetsData(widgets, 'form', data)
- ... invariant_errors = form.checkInvariants(self.form_fields,
+ ... invariant_errors = form.checkInvariants(self.form_fields,
... data)
... if errors:
... print 'There were field errors:'
@@ -300,7 +300,7 @@
type="text" value="bob" />
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="142.0" />
{'max_size': 142.0,
'min_size': 42.0,
@@ -319,7 +319,7 @@
type="text" value="bob" />
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="14.0" />
{'max_size': 14.0,
'min_size': 42.0,
@@ -339,7 +339,7 @@
<span class="error">Required input is missing.</span>
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="14.0" />
{'max_size': 14.0,
'min_size': 42.0}
@@ -358,7 +358,7 @@
<span class="error">Required input is missing.</span>
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="" />
<span class="error">Required input is missing.</span>
{'min_size': 42.0}
@@ -411,7 +411,7 @@
... return '\n'.join([w() for w in widgets])
>>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="" />
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
@@ -419,7 +419,7 @@
type="text" value="" />
Note that, in this case, we got the values from the request, because
-we used an old request. If we want to redraw the form after processing a
+we used an old request. If we want to redraw the form after processing a
request, it is safest to pass ignore_request = True to setUpWidgets so that
the form is redrawn with the values as found in the object, not on the request.
@@ -495,11 +495,11 @@
... print 'There were invariant errors:'
... for error in invariant_errors:
... print error
- ...
+ ...
... if not errors and not invariant_errors:
... changed = form.applyChanges(
... self.context, self.form_fields, data)
- ...
+ ...
... else:
... data = changed = None
...
@@ -549,7 +549,7 @@
>>> pprint(MyForm(order, request)()) # doctest: +NORMALIZE_WHITESPACE
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
<input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
@@ -563,7 +563,7 @@
because the new and old values are the same.
The code we included in `MyForm` above is generic: it applies to any
-edit form.
+edit form.
Actions
=======
@@ -694,7 +694,7 @@
... result.append('There were errors:')
... for error in self.errors:
... result.append(str(error))
- ...
+ ...
... for w in self.widgets:
... result.append(w())
... error = w.error()
@@ -761,13 +761,13 @@
>>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="142.0" />
- <input type="submit" id="form.actions.edit" name="form.actions.edit"
+ <input type="submit" id="form.actions.edit" name="form.actions.edit"
value="Edit" class="button" />
In this case, we didn't get any output about changes because the
@@ -778,17 +778,17 @@
>>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
No changes
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="142.0" />
<input type="submit" id="form.actions.edit" name="form.actions.edit"
value="Edit" class="button" />
This time, we got a status message indicating that there weren't any
-changes.
+changes.
Let's try changing some data:
@@ -798,11 +798,11 @@
There were errors:
(u'Invalid floating point data', <exceptions.ValueError instance at ...>)
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="10,0" />
<span class="error">Invalid floating point data</span>
<input type="submit" id="form.actions.edit" name="form.actions.edit"
@@ -815,11 +815,11 @@
There were errors:
Maximum is less than Minimum
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="42.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="10.0" />
<input type="submit" id="form.actions.edit" name="form.actions.edit"
value="Edit" class="button" />
@@ -830,11 +830,11 @@
>>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
Object updated
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="1.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="10.0" />
<input type="submit" id="form.actions.edit" name="form.actions.edit"
value="Edit" class="button" />
@@ -863,7 +863,7 @@
A constructor
`validate`
- A default validation method
+ A default validation method
`__call__`
To render the form
@@ -893,7 +893,7 @@
Subclasses may:
-- Provide a label function or message id to produce
+- Provide a label function or message id to produce
a form label.
- Override the setUpWidgets method to control how widgets are
@@ -901,7 +901,7 @@
- Override the template. The form defines variables:
- status
+ status
providing a short summary of the operation performed.
widgets
@@ -925,11 +925,11 @@
... else:
... self.status = 'No changes'
-We inherited most of our behavior from the base class.
+We inherited most of our behavior from the base class.
We also used the `action` decorator. The action decorator:
-- creates an `actions` variable if one isn't aleady created,
+- creates an `actions` variable if one isn't aleady created,
- defines an action with the given label and any other arguments, and
@@ -946,11 +946,11 @@
>>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
No changes
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="1.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="10.0" />
<input type="submit" id="form.actions.edit" name="form.actions.edit"
value="Edit" class="button" />
@@ -960,11 +960,11 @@
There were errors
Invalid: Maximum is less than Minimum
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="20.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="10.0" />
<input type="submit" id="form.actions.edit" name="form.actions.edit"
value="Edit" class="button" />
@@ -973,11 +973,11 @@
>>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
Object updated
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="20.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="30.0" />
<input type="submit" id="form.actions.edit" name="form.actions.edit"
value="Edit" class="button" />
@@ -1005,11 +1005,11 @@
>>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
No changes
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="20.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="30.0" />
<input type="submit" id="form.actions.apply" name="form.actions.apply"
value="Apply" class="button" />
@@ -1019,25 +1019,25 @@
There were errors
Invalid: Maximum is less than Minimum
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="40.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="30.0" />
<input type="submit" id="form.actions.apply" name="form.actions.apply"
value="Apply" class="button" />
>>> request.form['form.max_size'] = u'50.0'
- >>> print MyForm(order, request)()
+ >>> print MyForm(order, request)()
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Updated on ... ... ... ...:...:...
1
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size" size="10"
+ <input class="textType" id="form.min_size" name="form.min_size" size="10"
type="text" value="40.0" />
- <input class="textType" id="form.max_size" name="form.max_size" size="10"
+ <input class="textType" id="form.max_size" name="form.max_size" size="10"
type="text" value="50.0" />
<input type="submit" id="form.actions.apply" name="form.actions.apply"
value="Apply" class="button" />
@@ -1047,7 +1047,7 @@
>>> order.min_size
40.0
-
+
Note that `EditForm` shows the date and time when content are
modified.
@@ -1118,10 +1118,10 @@
type="text" value="50.0" />
<input class="textType" id="form.title" name="form.title" size="20"
type="text" value="" />
- <input class="textType" id="form.description" name="form.description"
+ <input class="textType" id="form.description" name="form.description"
size="20"
type="text" value="" />
- <input type="submit" id="form.actions.apply" name="form.actions.apply"
+ <input type="submit" id="form.actions.apply" name="form.actions.apply"
value="Apply" class="button" />
>>> request.form['form.name'] = u'bob'
@@ -1143,12 +1143,12 @@
type="text" value="20.0" />
<input class="textType" id="form.title" name="form.title" size="20"
type="text" value="Widgets" />
- <input class="textType" id="form.description" name="form.description"
+ <input class="textType" id="form.description" name="form.description"
size="20"
type="text" value="Need more widgets" />
<input type="submit" id="form.actions.apply" name="form.actions.apply"
value="Apply" class="button" />
-
+
>>> order.min_size
10.0
@@ -1181,7 +1181,7 @@
the same way by `setUpWidgets` by passing the dictionary as an
`adapters` keyword argument.
-
+
Named Widget Access
===================
@@ -1215,29 +1215,29 @@
`IDescriptive`:
>>> class MyForm(form.EditForm):
- ... form_fields = form.Fields(IOrder['name'],
+ ... form_fields = form.Fields(IOrder['name'],
... IDescriptive['title'])
... actions = ()
>>> print MyForm(order, TestRequest())() # doctest: +NORMALIZE_WHITESPACE
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.title" name="form.title" size="20"
+ <input class="textType" id="form.title" name="form.title" size="20"
type="text" value="Widgets" />
You can also use stand-alone fields:
>>> class MyForm(form.EditForm):
... form_fields = form.Fields(
- ... schema.TextLine(__name__='name', title=u"Who?"),
+ ... schema.TextLine(__name__='name', title=u"Who?"),
... IDescriptive['title'],
... )
... actions = ()
>>> print MyForm(order, TestRequest())() # doctest: +NORMALIZE_WHITESPACE
- <input class="textType" id="form.name" name="form.name" size="20"
+ <input class="textType" id="form.name" name="form.name" size="20"
type="text" value="bob" />
- <input class="textType" id="form.title" name="form.title" size="20"
+ <input class="textType" id="form.title" name="form.title" size="20"
type="text" value="Widgets" />
But make sure the fields have a '__name__', as was done above.
@@ -1251,19 +1251,19 @@
>>> class MyExpandedForm(form.Form):
... form_fields = (
- ... MyForm.form_fields
+ ... MyForm.form_fields
... +
... form.Fields(IDescriptive['description'])
... )
... actions = ()
- >>> print MyExpandedForm(order, TestRequest())()
+ >>> print MyExpandedForm(order, TestRequest())()
... # doctest: +NORMALIZE_WHITESPACE
- <input class="textType" id="form.name" name="form.name"
+ <input class="textType" id="form.name" name="form.name"
size="20" type="text" value="" />
- <input class="textType" id="form.title" name="form.title"
+ <input class="textType" id="form.title" name="form.title"
size="20" type="text" value="" />
- <input class="textType" id="form.description" name="form.description"
+ <input class="textType" id="form.description" name="form.description"
size="20" type="text" value="" />
Using fields for display
@@ -1279,13 +1279,13 @@
... +
... form.Fields(IOrder).select('min_size', 'max_size')
... )
-
+
>>> print MyForm(order, TestRequest())() # doctest: +NORMALIZE_WHITESPACE
bob
- <input class="textType" id="form.min_size" name="form.min_size"
+ <input class="textType" id="form.min_size" name="form.min_size"
size="10" type="text" value="10.0" />
- <input class="textType" id="form.max_size" name="form.max_size"
+ <input class="textType" id="form.max_size" name="form.max_size"
size="10" type="text" value="20.0" />
<input type="submit" id="form.actions.apply" name="form.actions.apply"
value="Apply" class="button" />
@@ -1295,7 +1295,7 @@
>>> class MyForm(form.EditForm):
... form_fields = form.Fields(IOrder, for_display=True
... ).select('name', 'min_size', 'max_size')
-
+
>>> print MyForm(order, TestRequest())() # doctest: +NORMALIZE_WHITESPACE
bob
10.0
@@ -1313,7 +1313,7 @@
`for_input` option when setting up form_fields:
>>> class MyForm(form.Form):
- ... form_fields = form.Fields(IOrder, for_input=True,
+ ... form_fields = form.Fields(IOrder, for_input=True,
... render_context=True)
... form_fields = form_fields.omit('now')
...
@@ -1321,13 +1321,13 @@
>>> print MyForm(order, TestRequest())() # doctest: +NORMALIZE_WHITESPACE
- <input class="textType" id="form.identifier" name="form.identifier"
+ <input class="textType" id="form.identifier" name="form.identifier"
size="10" type="text" value="1" />
- <input class="textType" id="form.name" name="form.name"
+ <input class="textType" id="form.name" name="form.name"
size="20" type="text" value="bob" />
- <input class="textType" id="form.min_size" name="form.min_size"
+ <input class="textType" id="form.min_size" name="form.min_size"
size="10" type="text" value="10.0" />
- <input class="textType" id="form.max_size" name="form.max_size"
+ <input class="textType" id="form.max_size" name="form.max_size"
size="10" type="text" value="20.0" />
Displaying or editing raw data
@@ -1358,11 +1358,11 @@
>>> print MyForm(None, TestRequest())() # doctest: +NORMALIZE_WHITESPACE
42
- <input class="textType" id="form.name" name="form.name"
+ <input class="textType" id="form.name" name="form.name"
size="20" type="text" value="sally" />
- <input class="textType" id="form.min_size" name="form.min_size"
+ <input class="textType" id="form.min_size" name="form.min_size"
size="10" type="text" value="" />
- <input class="textType" id="form.max_size" name="form.max_size"
+ <input class="textType" id="form.max_size" name="form.max_size"
size="10" type="text" value="" />
If data are passed in the request, they override initial data for
@@ -1374,11 +1374,11 @@
>>> request.form['form.max_size'] = u'100'
>>> print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE
42
- <input class="textType" id="form.name" name="form.name"
+ <input class="textType" id="form.name" name="form.name"
size="20" type="text" value="fred" />
- <input class="textType" id="form.min_size" name="form.min_size"
+ <input class="textType" id="form.min_size" name="form.min_size"
size="10" type="text" value="" />
- <input class="textType" id="form.max_size" name="form.max_size"
+ <input class="textType" id="form.max_size" name="form.max_size"
size="10" type="text" value="100.0" />
We'll get display fields if we ask for display fields when setting up
@@ -1429,11 +1429,11 @@
>>> print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE
42
- <input class="textType" id="form.name" name="form.name"
+ <input class="textType" id="form.name" name="form.name"
size="20" type="text" value="sally" />
- <input class="textType" id="form.min_size" name="form.min_size"
+ <input class="textType" id="form.min_size" name="form.min_size"
size="10" type="text" value="" />
- <input class="textType" id="form.max_size" name="form.max_size"
+ <input class="textType" id="form.max_size" name="form.max_size"
size="10" type="text" value="" />
@@ -1517,11 +1517,11 @@
>>> print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
- <input class="textType" id="form.name" name="form.name"
+ <input class="textType" id="form.name" name="form.name"
size="20" type="text" value="fred" />
- <input class="textType" id="form.min_size" name="form.min_size"
+ <input class="textType" id="form.min_size" name="form.min_size"
size="10" type="text" value="" />
- <input class="textType" id="form.max_size" name="form.max_size"
+ <input class="textType" id="form.max_size" name="form.max_size"
size="10" type="text" value="100.0" />
<span class="dateTime">2002 12 2 12:30:00 </span>
Modified: Zope3/trunk/src/zope/formlib/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/formlib/interfaces.py 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/interfaces.py 2005-10-05 20:09:32 UTC (rev 38778)
@@ -34,7 +34,7 @@
def reConstraint(pat, explanation):
pat = re.compile(pat)
-
+
def constraint(value):
if prefix_re.match(value):
return True
@@ -85,7 +85,7 @@
prefix
The form-field prefix.
-
+
for_display
A flag indicating whether the form-field is to be used
for display. See IFormField.
@@ -106,8 +106,8 @@
rendered value. See IFormField.
"""
-
+
def Fields(*arguments, **options):
"""Create form-fields collection (IFormFields)
@@ -132,13 +132,13 @@
The form-field prefix for new form-fields created.
When form-field collections are passed, their contents keep
their existing prefixes are retained.
-
+
for_display
A flag indicating whether the form-fiellds are to be used
for display. This value is used for for_display attributes
of all created form fields. This option does not effect
input from form-field collections.
-
+
for_input
A flag indicating whether the form-fiellds are to be used
for input. This value is used for for_input attributes
@@ -148,10 +148,10 @@
render_context
A flag indicating whether the default values to render
should come from the form context. See IFormField.
-
+
"""
- def setUpInputWidgets(form_fields, form_prefix, context, request,
+ def setUpInputWidgets(form_fields, form_prefix, context, request,
ignore_request=False):
"""Set up widgets for input
@@ -173,7 +173,7 @@
"""
def setUpEditWidgets(form_fields, form_prefix, context, request,
- adapters=None, for_display=False,
+ adapters=None, for_display=False,
ignore_request=False):
"""Set up widgets for editing or displaying content
@@ -197,7 +197,7 @@
If the ignore_request option is passed a true value, then
widget's rendered data will be set from the context, and user
- inputs will be ignored.
+ inputs will be ignored.
"""
def setUpDataWidgets(form_fields, form_prefix, context, request, data=(),
@@ -222,7 +222,7 @@
If the ignore_request option is passed a true value, then
widget's rendered data will be set from the passed data or
from field defaults, and user inputs will be ignored.
-
+
"""
def getWidgetsData(widgets, form_prefix, data):
@@ -232,7 +232,7 @@
are added to the data argument, which must be a mapping
argument. The keys in the output mapping are
widget/form-field names without the form prefix.
-
+
"""
def checkInvariants(form_fields, form_data):
@@ -254,7 +254,7 @@
each field. If an adapters mapping is passed, it will be used
as a cache. Typically, it would be a mapping object populated
when setUpEditWidgets was called.
-
+
"""
def Action(label, **options):
@@ -294,7 +294,7 @@
or may return None to indicate that the form should generate
it's own output.
- failure
+ failure
A handler, called when the the action was submitted and
there are validation errors. The handler may be provided as
either a callable or a method name. If the handler is
@@ -328,7 +328,7 @@
data
A bag of extra information that can be used by handlers,
validators, or conditions.
-
+
"""
def action(label, **options):
@@ -346,7 +346,7 @@
def handle_edit(self, action, data):
...
-
+
"""
# XXX should rename this to something like "submitted".
@@ -380,7 +380,7 @@
The FormBase class provides reuasable implementation for creating
forms. It implements ISubPage, IPage, and IFormBaseCustomization.
Subclasses will override or use attributes defined by
- IFormBaseCustomization.
+ IFormBaseCustomization.
""")
class IFormBaseCustomization(ISubPage, IPage):
@@ -391,7 +391,7 @@
Note that the update and render methods are designed to to work
together. If you override one, you probably need to override the
other, unless you use original versions in your override.
-
+
"""
label = interface.Attribute("A label to display at the top of a form")
@@ -453,7 +453,7 @@
2. You can register an alternate named template, named
"default" for your form.
-
+
""")
def resetForm():
@@ -576,7 +576,7 @@
render_context = schema.Choice(
title=u"Should the rendered value come from the form context?",
description=u"""\
-
+
If this attribute has a true value, and there is no other
source of rendered data, then use data from the form context
to set the rendered value for the widget. This attribute is
@@ -624,10 +624,10 @@
- There is user input and user input is not being ignored, or
- Data for the value is passed to setUpWidgets.
-
+
"""
)
-
+
class IWidgets(interface.Interface):
"""A widget collection
@@ -669,7 +669,7 @@
Widgets should have different names in the two collections.
The bahavior is undefined if the names overlap.
-
+
"""
class IForm(interface.Interface):
@@ -677,7 +677,7 @@
This exists primarily to provide something for which to register
form-related conponents.
-
+
"""
class ISubPageForm(IForm, ISubPage):
@@ -685,7 +685,7 @@
The rendered output must not have a form tag. It is the
responsibility of the surrounding page to supply a form tag.
-
+
"""
class IPageForm(IForm, IPage):
@@ -708,7 +708,7 @@
This is a callable object that will be passed a form and an
action and that returns a boolean to indicate whether the
action is available.
-
+
""")
validator = interface.Attribute(
@@ -717,7 +717,7 @@
This is a callable object that will be passed a form and an
action and that returns a (possibly empty) list of widget
input errors.
-
+
""")
def available():
@@ -758,7 +758,7 @@
Note that the other methods defined in this interface are
valid only after the action has been bound to a form.
"""
-
+
class IActions(interface.Interface):
"""An action collection
@@ -787,7 +787,7 @@
Actions should have different names in the two collections.
The bahavior is undefined if the names overlap.
-
+
"""
class IBoundAction(IAction):
Modified: Zope3/trunk/src/zope/formlib/namedtemplate.py
===================================================================
--- Zope3/trunk/src/zope/formlib/namedtemplate.py 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/namedtemplate.py 2005-10-05 20:09:32 UTC (rev 38778)
@@ -48,8 +48,8 @@
def __call__(self, descriptor):
return NamedTemplateImplementation(descriptor, self.view_type)
-
+
class NamedTemplate(object):
def __init__(self, name):
@@ -62,8 +62,8 @@
def __call__(self, instance, *args, **kw):
self.__get__(instance)(*args, **kw)
-
+
# XXX need test
class NamedTemplatePathAdapter(object):
Modified: Zope3/trunk/src/zope/formlib/page.py
===================================================================
--- Zope3/trunk/src/zope/formlib/page.py 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/page.py 2005-10-05 20:09:32 UTC (rev 38778)
@@ -22,7 +22,7 @@
class Page(BrowserView):
"""Simple page-support class
- """
+ """
interface.implements(IPage)
Modified: Zope3/trunk/src/zope/formlib/page.txt
===================================================================
--- Zope3/trunk/src/zope/formlib/page.txt 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/page.txt 2005-10-05 20:09:32 UTC (rev 38778)
@@ -35,14 +35,14 @@
- Input processing
- - Actions/buttons
+ - Actions/buttons
A major goal is to make creating pages simple and explicit
Creating simple pages
=====================
-To create a page, which is an object that is published as a page,
+To create a page, which is an object that is published as a page,
you need to provide an object that:
- has a __call__ method and that
Modified: Zope3/trunk/src/zope/formlib/pageform.pt
===================================================================
--- Zope3/trunk/src/zope/formlib/pageform.pt 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/pageform.pt 2005-10-05 20:09:32 UTC (rev 38778)
@@ -44,13 +44,13 @@
<div class="form-status"
tal:define="status view/status"
tal:condition="status">
-
+
<div class="summary"
i18n:translate=""
tal:content="view/status">
Form status summary
</div>
-
+
<ul class="errors" tal:condition="view/errors">
<li tal:repeat="error view/error_views">
<span tal:replace="structure error">Error Type</span>
@@ -121,8 +121,8 @@
<metal:block define-slot="above_buttons" />
</div>
<div id="actionsView">
- <span class="actionButtons"
- tal:condition="view/availableActions"
+ <span class="actionButtons"
+ tal:condition="view/availableActions"
metal:define-slot="bottom_buttons">
<input tal:repeat="action view/actions"
tal:replace="structure action/render"
Modified: Zope3/trunk/src/zope/formlib/subpageform.pt
===================================================================
--- Zope3/trunk/src/zope/formlib/subpageform.pt 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/subpageform.pt 2005-10-05 20:09:32 UTC (rev 38778)
@@ -68,13 +68,13 @@
onmouseout="toggleFormFieldHelp(this,0)"
style="cursor: help">
<span class="required" tal:condition="widget/required"
- >*</span><span i18n:translate=""
+ >*</span><span i18n:translate=""
tal:content="widget/label">label</span>
</label>
<label tal:condition="python:not hint"
tal:attributes="for widget/name">
<span class="required" tal:condition="widget/required"
- >*</span><span i18n:translate=""
+ >*</span><span i18n:translate=""
tal:content="widget/label">label</span>
</label>
</td>
Modified: Zope3/trunk/src/zope/formlib/tests.py
===================================================================
--- Zope3/trunk/src/zope/formlib/tests.py 2005-10-05 20:00:24 UTC (rev 38777)
+++ Zope3/trunk/src/zope/formlib/tests.py 2005-10-05 20:09:32 UTC (rev 38778)
@@ -55,7 +55,7 @@
if getattr(status, 'mapping', 0):
status = zope.i18n.interpolate(status, status.mapping)
print status
-
+
result = []
if self.errors:
More information about the Zope3-Checkins
mailing list