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

Marius Gedminas marius at pov.lt
Thu Mar 23 10:32:51 EST 2006


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

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

-=-
Modified: Zope3/branches/3.2/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.2/doc/CHANGES.txt	2006-03-23 15:24:19 UTC (rev 66134)
+++ Zope3/branches/3.2/doc/CHANGES.txt	2006-03-23 15:32:51 UTC (rev 66135)
@@ -10,6 +10,8 @@
 
     Bug fixes
 
+      - Fixed issue 573: @form.action(failure='name_of_method') didn't work.
+
       - Fixed issue 568: Typo in basicskin css file.
 
       - Fixed issue 560: Bug in default AddView class.

Modified: Zope3/branches/3.2/src/zope/formlib/form.py
===================================================================
--- Zope3/branches/3.2/src/zope/formlib/form.py	2006-03-23 15:24:19 UTC (rev 66134)
+++ Zope3/branches/3.2/src/zope/formlib/form.py	2006-03-23 15:32:51 UTC (rev 66135)
@@ -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/branches/3.2/src/zope/formlib/form.txt
===================================================================
--- Zope3/branches/3.2/src/zope/formlib/form.txt	2006-03-23 15:24:19 UTC (rev 66134)
+++ Zope3/branches/3.2/src/zope/formlib/form.txt	2006-03-23 15:32:51 UTC (rev 66135)
@@ -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