web/uicfg.py
branchstable
changeset 1944 a1b1d4f8482c
parent 1878 204b79e3e0ec
child 1977 606923dff11b
--- a/web/uicfg.py	Tue May 26 18:22:24 2009 +0200
+++ b/web/uicfg.py	Tue May 26 19:36:40 2009 +0200
@@ -66,13 +66,10 @@
 """
 __docformat__ = "restructuredtext en"
 
+from cubicweb import neg_role
 from cubicweb.rtags import RelationTags, RelationTagsBool, RelationTagsSet
 from cubicweb.web import formwidgets
 
-# primary view configuration ##################################################
-
-def dual_role(role):
-    return role == 'subject' and 'object' or 'subject'
 
 def card_from_role(card, role):
     if role == 'subject':
@@ -80,10 +77,12 @@
     assert role in ('object', 'sobject'), repr(role)
     return card[1]
 
+# primary view configuration ##################################################
+
 def init_primaryview_section(rtag, sschema, rschema, oschema, role):
     if rtag.get(sschema, rschema, oschema, role) is None:
         card = card_from_role(rschema.rproperty(sschema, oschema, 'cardinality'), role)
-        composed = rschema.rproperty(sschema, oschema, 'composite') == dual_role(role)
+        composed = rschema.rproperty(sschema, oschema, 'composite') == neg_role(role)
         if rschema.is_final():
             if rschema.meta or oschema.type in ('Password', 'Bytes'):
                 section = 'hidden'