[Zope3-checkins] SVN: Zope3/trunk/ Reverted revisions 65782 and
65783, they broke the functional tests.
Benji York
benji at zope.com
Sun Mar 5 16:53:21 EST 2006
Log message for revision 65826:
Reverted revisions 65782 and 65783, they broke the functional tests.
Changed:
U Zope3/trunk/doc/CHANGES.txt
D Zope3/trunk/src/zope/app/form/browser/sequencewidget.pt
U Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2006-03-05 16:32:34 UTC (rev 65825)
+++ Zope3/trunk/doc/CHANGES.txt 2006-03-05 21:53:21 UTC (rev 65826)
@@ -52,9 +52,6 @@
Bug Fixes
- - Fixed two bugs in SequenceWidgets: an exception was raised
- on rendering and the errors of the subwidgets weren't displayed.
-
- Fixed issue 560: Bug in default AddView class.
- Fixed issue 546: non-ASCII docstring cause
Deleted: Zope3/trunk/src/zope/app/form/browser/sequencewidget.pt
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/sequencewidget.pt 2006-03-05 16:32:34 UTC (rev 65825)
+++ Zope3/trunk/src/zope/app/form/browser/sequencewidget.pt 2006-03-05 21:53:21 UTC (rev 65826)
@@ -1,28 +0,0 @@
-<table border="0" class="sequencewidget">
- <tr tal:repeat="widget view/widgets">
- <td>
- <input class="editcheck" type="checkbox"
- tal:attributes="
- name string:${view/name}.remove_${repeat/widget/index}"
- tal:condition="view/need_delete" />
- </td>
- <td>
- <span tal:define="error widget/error"
- tal:replace="structure error" tal:condition="error" />
- <input tal:replace="structure widget" />
- </td>
- </tr>
- <tr>
- <td colspan="2">
- <input type="submit" value="Remove selected items"
- tal:condition="view/need_delete"
- tal:attributes="name string:${view/name}.remove"
- i18n:attributes="value remove-selected-items" />
- <input type="submit" value="Add"
- tal:condition="view/need_add"
- tal:attributes="name string:${view/name}.add"
- i18n:attributes="value add-button" />
- </td>
- </tr>
-</table>
-<input tal:replace="structure view/marker" />
Modified: Zope3/trunk/src/zope/app/form/browser/sequencewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/sequencewidget.py 2006-03-05 16:32:34 UTC (rev 65825)
+++ Zope3/trunk/src/zope/app/form/browser/sequencewidget.py 2006-03-05 21:53:21 UTC (rev 65826)
@@ -26,7 +26,6 @@
from zope.app.form import InputWidget
from zope.app.form.browser.widget import BrowserWidget
from zope.app.form.browser.widget import DisplayWidget, renderElement
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.i18n import ZopeMessageFactory as _
@@ -39,8 +38,6 @@
implements(IInputWidget)
- template = ViewPageTemplateFile('sequencewidget.pt')
-
_type = tuple
def __init__(self, context, field, request, subwidget=None):
@@ -53,28 +50,56 @@
def __call__(self):
"""Render the widget"""
- self._update()
- return self.template()
+ assert self.context.value_type is not None
- def _update(self):
- """Set various attributes for the template"""
+ render = []
+
+ # length of sequence info
sequence = self._getRenderedValue()
num_items = len(sequence)
- self.need_add = (not self.context.max_length
- or num_items < self.context.max_length)
- self.need_delete = num_items and num_items > self.context.min_length
- self.marker = self._getPresenceMarker(num_items)
+ min_length = self.context.min_length
+ max_length = self.context.max_length
- def widgets(self):
- """Return a list of widgets to display"""
- sequence = self._getRenderedValue()
- result = []
- for i, value in enumerate(sequence):
+ # generate each widget from items in the sequence - adding a
+ # "remove" button for each one
+ for i in range(num_items):
+ value = sequence[i]
+ render.append('<tr><td>')
+ if num_items > min_length:
+ render.append(
+ '<input class="editcheck" type="checkbox" '
+ 'name="%s.remove_%d" />\n' % (self.name, i)
+ )
widget = self._getWidget(i)
widget.setRenderedValue(value)
- result.append(widget)
- return result
+ error = widget.error()
+ if error:
+ render.append(error)
+ render.append('\n')
+ render.append(widget() + '</td></tr>\n')
+ # possibly generate the "remove" and "add" buttons
+ buttons = ''
+ if render and num_items > min_length:
+ button_label = _('remove-selected-items', "Remove selected items")
+ button_label = translate(button_label, context=self.request,
+ default=button_label)
+ buttons += ('<input type="submit" value="%s" name="%s.remove"/>'
+ % (button_label, self.name))
+ if max_length is None or num_items < max_length:
+ field = self.context.value_type
+ button_label = _('Add %s')
+ button_label = translate(button_label, context=self.request,
+ default=button_label)
+ button_label = button_label % (field.title or field.__name__)
+ buttons += '<input type="submit" name="%s.add" value="%s" />\n' % (
+ self.name, button_label)
+ if buttons:
+ render.append('<tr><td>%s</td></tr>\n' % buttons)
+
+ return ('<table border="0">\n%s</table>\n%s'
+ % (''.join(render), self._getPresenceMarker(num_items)))
+
def _getWidget(self, i):
"""Return a widget for the i-th number of the sequence.
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py 2006-03-05 16:32:34 UTC (rev 65825)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_sequencewidget.py 2006-03-05 21:53:21 UTC (rev 65826)
@@ -58,10 +58,6 @@
self._widget = self._WidgetFactory(
self.field, self.field.value_type, self.request)
- def setUp(self):
- setup.placefulSetUp()
- self.setUpContent()
-
def _FieldFactory(self, **kw):
kw.update({
'__name__': u'foo',
@@ -305,17 +301,10 @@
>>> print widget()
<BLANKLINE>
...
- <tr>
- <td>
- <input class="editcheck" type="checkbox"
- name="field.foo.remove_0" />
- </td>
- <td>
- <input class="textType" id="field.foo.0.bar"
- name="field.foo.0.bar"
- size="20" type="text" value="" />
- </td>
- </tr>
+ <tr><td><input class="editcheck" type="checkbox"
+ name="field.foo.remove_0" />
+ <input class="textType" id="field.foo.0.bar" name="field.foo.0.bar"
+ size="20" type="text" value="" /></td></tr>
...
However, if we call getInputValue or hasValidInput, the
@@ -327,18 +316,11 @@
>>> print widget()
<BLANKLINE>
...
- <tr>
- <td>
- <input class="editcheck" type="checkbox"
- name="field.foo.remove_0" />
- </td>
- <td>
- <span class="error">Required input is missing.</span>
- <input class="textType" id="field.foo.0.bar"
- name="field.foo.0.bar"
- size="20" type="text" value="" />
- </td>
- </tr>
+ <tr><td><input class="editcheck" type="checkbox"
+ name="field.foo.remove_0" />
+ <span class="error">Required input is missing.</span>
+ <input class="textType" id="field.foo.0.bar" name="field.foo.0.bar"
+ size="20" type="text" value="" /></td></tr>
...
"""
@@ -408,14 +390,14 @@
def setUp(test):
- setup.placefulSetUp()
+ setup.placelessSetUp()
ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
ztapi.browserViewProviding(IWidgetInputError, WidgetInputErrorView,
IWidgetInputErrorView)
def tearDown(test):
- setup.placefulTearDown()
+ setup.placelessTearDown()
def test_suite():
More information about the Zope3-Checkins
mailing list