164 |
164 |
165 # relations'section (eg primary/secondary/generic/metadata/generated) |
165 # relations'section (eg primary/secondary/generic/metadata/generated) |
166 |
166 |
167 def init_autoform_section(rtag, sschema, rschema, oschema, role): |
167 def init_autoform_section(rtag, sschema, rschema, oschema, role): |
168 if rtag.get(sschema, rschema, oschema, role) is None: |
168 if rtag.get(sschema, rschema, oschema, role) is None: |
169 if role == 'subject': |
169 if autoform_is_inlined.get(sschema, rschema, oschema, role): |
170 card = rschema.rproperty(sschema, oschema, 'cardinality')[0] |
170 section = 'generated' |
171 composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' |
171 elif sschema.is_metadata(rschema): |
|
172 section = 'metadata' |
172 else: |
173 else: |
173 card = rschema.rproperty(sschema, oschema, 'cardinality')[1] |
174 if role == 'subject': |
174 composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' |
175 card = rschema.rproperty(sschema, oschema, 'cardinality')[0] |
175 if sschema.is_metadata(rschema): |
176 composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' |
176 section = 'metadata' |
|
177 elif card in '1+': |
|
178 if not rschema.is_final() and composed: |
|
179 section = 'generated' |
|
180 else: |
177 else: |
181 section = 'primary' |
178 card = rschema.rproperty(sschema, oschema, 'cardinality')[1] |
182 elif rschema.is_final(): |
179 composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' |
183 section = 'secondary' |
180 if card in '1+': |
184 else: |
181 if not rschema.is_final() and composed: |
185 section = 'generic' |
182 # XXX why? probably because we want it unlined, though this |
|
183 # is not the case by default |
|
184 section = 'generated' |
|
185 else: |
|
186 section = 'primary' |
|
187 elif rschema.is_final(): |
|
188 section = 'secondary' |
|
189 else: |
|
190 section = 'generic' |
186 rtag.tag_relation((sschema, rschema, oschema, role), section) |
191 rtag.tag_relation((sschema, rschema, oschema, role), section) |
187 |
192 |
188 autoform_section = RelationTags('autoform_section', init_autoform_section, |
193 autoform_section = RelationTags('autoform_section', init_autoform_section, |
189 set(('primary', 'secondary', 'generic', |
194 set(('primary', 'secondary', 'generic', |
190 'metadata', 'generated'))) |
195 'metadata', 'generated'))) |