[Checkins] SVN: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.py recursively extrat errors from subforms
Laurent Mignon
Laurent.Mignon at softwareag.com
Tue May 26 15:14:07 EDT 2009
Log message for revision 100434:
recursively extrat errors from subforms
Changed:
U z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.py
-=-
Modified: z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.py
===================================================================
--- z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.py 2009-05-26 19:03:36 UTC (rev 100433)
+++ z3c.formext/branches/sagblmi-morecomponent/src/z3c/formext/group.py 2009-05-26 19:14:06 UTC (rev 100434)
@@ -25,6 +25,7 @@
from z3c.formext import interfaces
from z3c.form import group
+from z3c.form.interfaces import IMultipleErrors
class ExtJSGroup(group.Group):
@@ -57,11 +58,24 @@
# I shouldn't need the below security proxy
errors={},
formErrors=[])
- for error in errors:
- error = removeSecurityProxy(error)
- message = translate(error.message, context=self.request)
- if error.widget:
- self.jsonResponse['errors'][error.widget.id] = message
- else:
- self.jsonResponse['formErrors'].append(message)
+ #recursively extrat errors from subforms
+ def _extractErrors(errors):
+ if IMultipleErrors.providedBy(errors):
+ errors = errors.errors
+
+ for error in errors:
+ if IMultipleErrors.providedBy(error.error):
+ _extractErrors(error.error)
+ continue
+ #XXX
+ if hasattr(error.error, "message"):
+ error = removeSecurityProxy(error.error)
+ else:
+ error = removeSecurityProxy(error)
+ message = translate(error.message, context=self.request)
+ if error.widget:
+ self.jsonResponse['errors'][error.widget.id] = message
+ else:
+ self.jsonResponse['formErrors'].append(message)
+ _extractErrors(errors)
return data, errors
More information about the Checkins
mailing list