72 # primary view configuration ################################################## |
72 # primary view configuration ################################################## |
73 |
73 |
74 def dual_role(role): |
74 def dual_role(role): |
75 return 'object' if role == 'subject' else 'subject' |
75 return 'object' if role == 'subject' else 'subject' |
76 |
76 |
|
77 def card_from_role(card, role): |
|
78 if role == 'subject': |
|
79 return card[0] |
|
80 assert role in ('object', 'sobject'), repr(role) |
|
81 return card[1] |
|
82 |
77 def init_primaryview_section(rtag, sschema, rschema, oschema, role): |
83 def init_primaryview_section(rtag, sschema, rschema, oschema, role): |
78 if rtag.get(sschema, rschema, oschema, role) is None: |
84 if rtag.get(sschema, rschema, oschema, role) is None: |
79 card = rschema.rproperty(sschema, oschema, 'cardinality') |
85 card = card_from_role(rschema.rproperty(sschema, oschema, 'cardinality'), role) |
80 card = card[0] if role == 'subject' else card[1] |
|
81 composed = rschema.rproperty(sschema, oschema, 'composite') == dual_role(role) |
86 composed = rschema.rproperty(sschema, oschema, 'composite') == dual_role(role) |
82 if rschema.is_final(): |
87 if rschema.is_final(): |
83 if rschema.meta or oschema.type in ('Password', 'Bytes'): |
88 if rschema.meta or oschema.type in ('Password', 'Bytes'): |
84 section = 'hidden' |
89 section = 'hidden' |
85 else: |
90 else: |