similar method already exists stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 26 May 2009 19:36:40 +0200
branchstable
changeset 1944 a1b1d4f8482c
parent 1943 fb557b616c80
child 1945 2b59d9ae17ae
similar method already exists
web/uicfg.py
--- 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'