web/uicfg.py
branchtls-sprint
changeset 1746 67a9b86fd479
parent 1745 7e7f04d19a98
child 1747 d48613e65196
--- a/web/uicfg.py	Tue May 12 16:38:25 2009 +0200
+++ b/web/uicfg.py	Tue May 12 16:47:03 2009 +0200
@@ -74,10 +74,15 @@
 def dual_role(role):
     return 'object' if role == 'subject' else 'subject'
 
+def card_from_role(card, role):
+    if role == 'subject':
+        return card[0]
+    assert role in ('object', 'sobject'), repr(role)
+    return card[1]
+
 def init_primaryview_section(rtag, sschema, rschema, oschema, role):
     if rtag.get(sschema, rschema, oschema, role) is None:
-        card = rschema.rproperty(sschema, oschema, 'cardinality')
-        card = card[0] if role == 'subject' else card[1]
+        card = card_from_role(rschema.rproperty(sschema, oschema, 'cardinality'), role)
         composed = rschema.rproperty(sschema, oschema, 'composite') == dual_role(role)
         if rschema.is_final():
             if rschema.meta or oschema.type in ('Password', 'Bytes'):