177 |
177 |
178 # relations'section (eg primary/secondary/generic/metadata/generated) |
178 # relations'section (eg primary/secondary/generic/metadata/generated) |
179 |
179 |
180 def init_autoform_section(rtag, sschema, rschema, oschema, role): |
180 def init_autoform_section(rtag, sschema, rschema, oschema, role): |
181 if rtag.get(sschema, rschema, oschema, role) is None: |
181 if rtag.get(sschema, rschema, oschema, role) is None: |
182 if role == 'subject': |
182 if autoform_is_inlined.get(sschema, rschema, oschema, role): |
183 card = rschema.rproperty(sschema, oschema, 'cardinality')[0] |
183 section = 'generated' |
184 composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' |
184 elif sschema.is_metadata(rschema): |
|
185 section = 'metadata' |
185 else: |
186 else: |
186 card = rschema.rproperty(sschema, oschema, 'cardinality')[1] |
187 if role == 'subject': |
187 composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' |
188 card = rschema.rproperty(sschema, oschema, 'cardinality')[0] |
188 if sschema.is_metadata(rschema): |
189 composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' |
189 section = 'metadata' |
190 else: |
190 elif card in '1+': |
191 card = rschema.rproperty(sschema, oschema, 'cardinality')[1] |
191 if not rschema.is_final() and composed: |
192 composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' |
192 section = 'generated' |
193 if card in '1+': |
193 else: |
194 if not rschema.is_final() and composed: |
194 section = 'primary' |
195 # XXX why? probably because we want it unlined, though this |
195 elif rschema.is_final(): |
196 # is not the case by default |
196 section = 'secondary' |
197 section = 'generated' |
197 else: |
198 else: |
198 section = 'generic' |
199 section = 'primary' |
|
200 elif rschema.is_final(): |
|
201 section = 'secondary' |
|
202 else: |
|
203 section = 'generic' |
199 rtag.tag_relation((sschema, rschema, oschema, role), section) |
204 rtag.tag_relation((sschema, rschema, oschema, role), section) |
200 |
205 |
201 autoform_section = RelationTags('autoform_section', init_autoform_section, |
206 autoform_section = RelationTags('autoform_section', init_autoform_section, |
202 set(('primary', 'secondary', 'generic', |
207 set(('primary', 'secondary', 'generic', |
203 'metadata', 'generated'))) |
208 'metadata', 'generated'))) |