[Zope3-checkins] SVN: Zope3/trunk/ Fixed issue 573: @form.action(failure='name_of_method') didn't work.

Marius Gedminas marius at pov.lt
Thu Mar 23 10:24:21 EST 2006


Log message for revision 66134:
  Fixed issue 573: @form.action(failure='name_of_method') didn't work.
  
  

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/formlib/form.py
  U   Zope3/trunk/src/zope/formlib/form.txt

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2006-03-22 20:07:11 UTC (rev 66133)
+++ Zope3/trunk/doc/CHANGES.txt	2006-03-23 15:24:19 UTC (rev 66134)
@@ -74,6 +74,8 @@
 
     Bug Fixes
 
+      - Fixed issue 573: @form.action(failure='name_of_method') didn't work.
+
       - Fixed two bugs in SequenceWidgets: an exception was raised
         on rendering and the errors of the subwidgets weren't displayed.
 

Modified: Zope3/trunk/src/zope/formlib/form.py
===================================================================
--- Zope3/trunk/src/zope/formlib/form.py	2006-03-22 20:07:11 UTC (rev 66133)
+++ Zope3/trunk/src/zope/formlib/form.py	2006-03-23 15:24:19 UTC (rev 66134)
@@ -506,7 +506,7 @@
 
 def _callify(f):
     if isinstance(f, str):
-        callable = lambda form, action, data: getattr(form, f)(action, data)
+        callable = lambda form, *args: getattr(form, f)(*args)
     else:
         callable = f
 

Modified: Zope3/trunk/src/zope/formlib/form.txt
===================================================================
--- Zope3/trunk/src/zope/formlib/form.txt	2006-03-22 20:07:11 UTC (rev 66133)
+++ Zope3/trunk/src/zope/formlib/form.txt	2006-03-23 15:24:19 UTC (rev 66134)
@@ -918,12 +918,15 @@
     ...     form_fields = form.Fields(IOrder, render_context=True)
     ...     form_fields = form_fields.omit('now')
     ...
-    ...     @form.action("Edit")
+    ...     @form.action("Edit", failure='handle_edit_action_failure')
     ...     def handle_edit_action(self, action, data):
     ...         if form.applyChanges(self.context, self.form_fields, data):
     ...             self.status = 'Object updated'
     ...         else:
     ...             self.status = 'No changes'
+    ...
+    ...     def handle_edit_action_failure(self, action, data, errors):
+    ...         self.status = 'There were %d errors.' % len(errors)
 
 We inherited most of our behavior from the base class.
 
@@ -957,7 +960,7 @@
 
     >>> request.form['form.min_size'] = u'20.0'
     >>> print MyForm(order, request)() # doctest: +NORMALIZE_WHITESPACE
-    There were errors
+    There were 1 errors.
     Invalid: Maximum is less than Minimum
     1
     <input class="textType" id="form.name" name="form.name" size="20"



More information about the Zope3-Checkins mailing list