[edit ctrl] fix bad interaction with fields: the loop on actual fields should be done in has_been_modified
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 07 Jun 2010 12:39:15 +0200
changeset 5676 aa04ccb8dd62
parent 5675 4535f8e57580
child 5679 0f2ded880d01
[edit ctrl] fix bad interaction with fields: the loop on actual fields should be done in has_been_modified
web/formfields.py
web/views/editcontroller.py
--- a/web/formfields.py	Mon May 31 19:33:43 2010 +0200
+++ b/web/formfields.py	Mon Jun 07 12:39:15 2010 +0200
@@ -418,6 +418,12 @@
         pass
 
     def has_been_modified(self, form):
+        for field in field.actual_fields(form):
+            if field._has_been_modified():
+                return True # XXX
+        return False # not modified
+
+    def _has_been_modified(self, form):
         # fields not corresponding to an entity attribute / relations
         # are considered modified
         if not self.eidparam or not self.role or not form.edited_entity.has_eid():
@@ -441,7 +447,7 @@
         except ProcessFormError:
             return True
         except UnmodifiedField:
-            return False
+            return False # not modified
         if previous_value == new_value:
             return False # not modified
         return True
--- a/web/views/editcontroller.py	Mon May 31 19:33:43 2010 +0200
+++ b/web/views/editcontroller.py	Mon Jun 07 12:39:15 2010 +0200
@@ -204,9 +204,8 @@
                 field = form.field_by_name(name, role, eschema=entity.e_schema)
             else:
                 field = form.field_by_name(name, role)
-            for field in field.actual_fields(form):
-                if field.has_been_modified(form):
-                    self.handle_formfield(form, field, rqlquery)
+            if field.has_been_modified(form):
+                self.handle_formfield(form, field, rqlquery)
         if self.errors:
             errors = dict((f.role_name(), unicode(ex)) for f, ex in self.errors)
             raise ValidationError(valerror_eid(entity.eid), errors)