From c1ca1ffcd5e1e2a655e15a903fab1b749db37321 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 30 Jun 2006 13:54:52 +0000
Subject: [PATCH] Handle KeyError exceptions specially in validate_all, because
 they are only caused by missing fields, and it must not be fatal.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8258 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/Form.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/product/ERP5Form/Form.py b/product/ERP5Form/Form.py
index a0563ef487..55426f2033 100644
--- a/product/ERP5Form/Form.py
+++ b/product/ERP5Form/Form.py
@@ -407,6 +407,7 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
         if they occur and raise a FormValidationError in the end if any
         Validation Errors occured.
         """
+#        import pdb; pdb.set_trace()
         result = {}
         errors = []
         for field in self.get_fields():
@@ -430,6 +431,8 @@ class ERP5Form(ZMIForm, ZopePageTemplate):
             except ValidationError, err:
                 #LOG('validate_all', 0, 'ValidationError: field.id = %s, err=%s' % (repr(field.id), repr(err)))
                 errors.append(err)
+            except KeyError, err:
+                LOG('ERP5Form/Form.py:validate_all', 0, 'KeyError : %s' % (err, ))
         if len(errors) > 0:
             raise FormValidationError(errors, result)
         return result
-- 
2.30.9