[forms] no crash if restore_previous_post has not be called, has in report bug form in management.py for instance
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 20 Apr 2010 18:09:56 +0200
changeset 5358 d4d294610ee7
parent 5355 3c703f3245dc
child 5359 d83a227df75c
[forms] no crash if restore_previous_post has not be called, has in report bug form in management.py for instance
web/form.py
web/views/management.py
--- a/web/form.py	Tue Apr 20 16:31:53 2010 +0200
+++ b/web/form.py	Tue Apr 20 18:09:56 2010 +0200
@@ -117,14 +117,16 @@
     def form_valerror(self):
         """the validation error exception if any"""
         if self.parent_form is None:
-            return self._form_valerror
+            # unset if restore_previous_post has not be called
+            return getattr(self, '_form_valerror', None)
         return self.parent_form.form_valerror
 
     @property
     def form_previous_values(self):
         """previously posted values (on validation error)"""
         if self.parent_form is None:
-            return self._form_previous_values
+            # unset if restore_previous_post has not be called
+            return getattr(self, '_form_previous_values', {})
         return self.parent_form.form_previous_values
 
     @iclassmethod
--- a/web/views/management.py	Tue Apr 20 16:31:53 2010 +0200
+++ b/web/views/management.py	Tue Apr 20 18:09:56 2010 +0200
@@ -198,7 +198,7 @@
         # creates a bug submission link if submit-mail is set
         if self._cw.vreg.config['submit-mail']:
             form = self._cw.vreg['forms'].select('base', self._cw, rset=None,
-                                             mainform=False)
+                                                 mainform=False)
             binfo = text_error_description(ex, excinfo, req, eversion, cversions)
             form.add_hidden('description', binfo,
                             # we must use a text area to keep line breaks