[editcontroller] a slight code reorganisation, in preparation for a fix
authorAurelien Campeas <aurelien.campeas@pythonian.fr>
Fri, 20 Nov 2015 12:29:13 +0100
changeset 11061 c01325774d21
parent 11060 3699fca78836
child 11062 40208f18c7c2
[editcontroller] a slight code reorganisation, in preparation for a fix * `entity` defined at method entry * a combined `continue` and a dedent of the next big block * some vertical white space Related to #8529868.
web/views/editcontroller.py
--- a/web/views/editcontroller.py	Tue Oct 20 16:05:36 2015 +0200
+++ b/web/views/editcontroller.py	Fri Nov 20 12:29:13 2015 +0100
@@ -280,7 +280,8 @@
         return eid
 
     def handle_formfield(self, form, field, rqlquery=None):
-        eschema = form.edited_entity.e_schema
+        entity = form.edited_entity
+        eschema = entity.e_schema
         try:
             for field, value in field.process_posted(form):
                 if not (
@@ -288,22 +289,27 @@
                     or
                     (field.role == 'object' and field.name in eschema.objrels)):
                     continue
+
                 rschema = self._cw.vreg.schema.rschema(field.name)
                 if rschema.final:
                     rqlquery.set_attribute(field.name, value)
+                    continue
+
+                if entity.has_eid():
+                    origvalues = set(data[0] for data in entity.related(field.name, field.role).rows)
                 else:
-                    if form.edited_entity.has_eid():
-                        origvalues = set(entity.eid for entity in form.edited_entity.related(field.name, field.role, entities=True))
-                    else:
-                        origvalues = set()
-                    if value is None or value == origvalues:
-                        continue # not edited / not modified / to do later
-                    if rschema.inlined and rqlquery is not None and field.role == 'subject':
-                        self.handle_inlined_relation(form, field, value, origvalues, rqlquery)
-                    elif form.edited_entity.has_eid():
-                        self.handle_relation(form, field, value, origvalues)
-                    else:
-                        form._cw.data['pending_others'].add( (form, field) )
+                    origvalues = set()
+
+                if value is None or value == origvalues:
+                    continue # not edited / not modified / to do later
+
+                if rschema.inlined and rqlquery is not None and field.role == 'subject':
+                    self.handle_inlined_relation(form, field, value, origvalues, rqlquery)
+                elif form.edited_entity.has_eid():
+                    self.handle_relation(form, field, value, origvalues)
+                else:
+                    form._cw.data['pending_others'].add( (form, field) )
+
         except ProcessFormError as exc:
             self.errors.append((field, exc))