[uicfg] Remove unpredictability from autoform_section initialization
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 16 Nov 2016 15:52:55 +0100
changeset 11853 c71339453c1e
parent 11852 dfcc3f74b3c8
child 11854 056de1196ef8
[uicfg] Remove unpredictability from autoform_section initialization It was attempting to guess smart default values by looking at the opposite relation (neg_role), but depending on the (random) ordering of the schema, it may or may not have been set yet, leading to unpredictable result with varying hash seed. Remove those fuzzy lookup all at once, it may change some (unreliable) things in your app but at least it's still a bit easier to explain. Closes #16272968
cubicweb/web/views/uicfg.py
--- a/cubicweb/web/views/uicfg.py	Mon Nov 21 14:55:27 2016 +0100
+++ b/cubicweb/web/views/uicfg.py	Wed Nov 16 15:52:55 2016 +0100
@@ -220,12 +220,7 @@
         formsections = self.init_get(sschema, rschema, oschema, role)
         if formsections is None:
             formsections = self.tag_container_cls()
-        if not any(tag.startswith('inlined') for tag in formsections):
-            if not rschema.final:
-                negsects = self.init_get(sschema, rschema, oschema, neg_role(role))
-                if 'main_inlined' in negsects:
-                    formsections.add('inlined_hidden')
-        key = _ensure_str_key( (sschema, rschema, oschema, role) )
+        key = _ensure_str_key((sschema, rschema, oschema, role))
         self._tagdefs[key] = formsections
 
     def _initfunc_step2(self, sschema, rschema, oschema, role):
@@ -243,12 +238,7 @@
             sectdict.setdefault('inlined', 'hidden')
         # ensure we have a tag for each form type
         if not 'main' in sectdict:
-            if not rschema.final and (
-                sectdict.get('inlined') == 'attributes' or
-                'inlined_attributes' in self.init_get(sschema, rschema, oschema,
-                                                      neg_role(role))):
-                sectdict['main'] = 'hidden'
-            elif sschema.is_metadata(rschema):
+            if sschema.is_metadata(rschema):
                 sectdict['main'] = 'metadata'
             else:
                 card, composed = _card_and_comp(sschema, rschema, oschema, role)