update rtags api tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 29 Apr 2009 10:29:03 +0200
branchtls-sprint
changeset 1533 bcd4bfff658b
parent 1532 111c52e0022f
child 1534 7edc063e8a91
update rtags api
entity.py
rtags.py
test/unittest_rtags.py
web/test/unittest_views_editforms.py
web/uicfg.py
web/views/autoform.py
web/views/bookmark.py
web/views/boxes.py
web/views/cwproperties.py
web/views/cwuser.py
web/views/schema.py
web/views/workflow.py
--- a/entity.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/entity.py	Wed Apr 29 10:29:03 2009 +0200
@@ -51,11 +51,11 @@
     def _dispatch_rtags(tags, rtype, role, stype, otype):
         for tag in tags:
             if tag in _MODE_TAGS:
-                uicfg.rmode.set_rtag(tag, rtype, role, stype, otype)
+                uicfg.rmode.tag_relation(tag, (stype, rtype, otype), role)
             elif tag in _CATEGORY_TAGS:
-                uicfg.rcategories.set_rtag(tag, rtype, role, stype, otype)
+                uicfg.rcategories.tag_relation(tag, (stype, rtype, otype), role)
             elif tag == 'inlineview':
-                uicfg.rinlined.set_rtag(True, rtype, role, stype, otype)
+                uicfg.rinlined.tag_relation(True, (stype, rtype, otype), role)
             else:
                 raise ValueError(tag)
 
@@ -127,7 +127,8 @@
                     if wdgname == 'StringWidget':
                         wdgname = 'TextInput'
                     widget = getattr(formwidgets, wdgname)
-                    AutomaticEntityForm.rwidgets.set_rtag(wdgname, rtype, 'subject', etype)
+                    AutomaticEntityForm.rwidgets.tag_relation(
+                        wdgname, (etype, rtype, '*'), 'subject')
         return super(_metaentity, mcs).__new__(mcs, name, bases, classdict)
 
 
--- a/rtags.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/rtags.py	Wed Apr 29 10:29:03 2009 +0200
@@ -6,88 +6,81 @@
 """
 __docformat__ = "restructuredtext en"
 
+
 class RelationTags(object):
-    """RelationTags instances are a tag store for full relation definitions :
+    """a tag store for full relation definitions :
 
-         (subject type, relation type, object type, role)
+         (subject type, relation type, object type, tagged)
 
     allowing to set tags using wildcard (eg '*') as subject type / object type
 
-    if `use_set` is True, a set of tags is associated to each key, and you
-    should use rtags / etype_rtags / add_rtag api. Otherwise, a single tag is
-    associated to each key, and you should use rtag / etype_rtag / set_rtag api.
+    This class associates a single tag to each key.
     """
 
-    def __init__(self, use_set=False):
-        self.use_set = use_set
+    def __init__(self):
         self._tagdefs = {}
 
     def __repr__(self):
         return repr(self._tagdefs)
 
-    def set_rtag(self, tag, rtype, role, stype='*', otype='*'):
-        assert not self.use_set
-        assert role in ('subject', 'object'), role
-        self._tagdefs[(str(rtype), role, str(stype), str(otype))] = tag
+    # dict compat
+    def __getitem__(self, key):
+        return self.get(*key)
+    __contains__ = __getitem__
 
-    def del_rtag(self, rtype, role, stype='*', otype='*'):
-        assert not self.use_set
-        assert role in ('subject', 'object'), role
-        del self._tagdefs[(str(rtype), role, str(stype), str(otype))]
+    def _get_keys(self, rtype, tagged, stype, otype):
+        assert tagged in ('subject', 'object'), tagged
+        keys = [(rtype, tagged, '*', '*'),
+                (rtype, tagged, '*', otype),
+                (rtype, tagged, stype, '*'),
+                (rtype, tagged, stype, otype)]
+        if stype == '*' or otype == '*':
+            keys.remove((rtype, tagged, '*', '*'))
+            if stype == '*':
+                keys.remove((rtype, tagged, '*', otype))
+            if otype == '*':
+                keys.remove((rtype, tagged, stype, '*'))
+        return keys
 
-    def rtag(self, rtype, role, stype='*', otype='*'):
-        assert not self.use_set
-        for key in reversed(self._get_keys(rtype, role, stype, otype)):
+    def tag_relation(self, tag, relation, tagged):
+        assert tagged in ('subject', 'object'), tagged
+        stype, rtype, otype = relation
+        self._tagdefs[(str(rtype), tagged, str(stype), str(otype))] = tag
+
+    def del_rtag(self, relation, tagged):
+        assert tagged in ('subject', 'object'), tagged
+        stype, rtype, otype = relation
+        del self._tagdefs[(str(rtype), tagged, str(stype), str(otype))]
+
+    def get(self, rtype, tagged, stype='*', otype='*'):
+        for key in reversed(self._get_keys(rtype, tagged, stype, otype)):
             try:
                 return self._tagdefs[key]
             except KeyError:
                 continue
         return None
 
-    def etype_rtag(self, etype, rtype, role, ttype='*'):
-        if role == 'subject':
-            return self.rtag(rtype, role, etype, ttype)
-        return self.rtag(rtype, role, ttype, etype)
+    def etype_get(self, etype, rtype, tagged, ttype='*'):
+        if tagged == 'subject':
+            return self.get(rtype, tagged, etype, ttype)
+        return self.get(rtype, tagged, ttype, etype)
+
+
 
-    def add_rtag(self, tag, rtype, role, stype='*', otype='*'):
-        assert self.use_set
-        assert role in ('subject', 'object'), role
-        rtags = self._tagdefs.setdefault((rtype, role, stype, otype), set())
+class RelationTagsSet(RelationTags):
+    """This class associates a set of tags to each key."""
+
+    def tag_relation(self, tag, relation, tagged):
+        assert tagged in ('subject', 'object'), tagged
+        stype, rtype, otype = relation
+        rtags = self._tagdefs.setdefault((rtype, tagged, stype, otype), set())
         rtags.add(tag)
 
-    def rtags(self, rtype, role, stype='*', otype='*'):
-        assert self.use_set
+    def get(self, rtype, tagged, stype='*', otype='*'):
         rtags = set()
-        for key in self._get_keys(rtype, role, stype, otype):
+        for key in self._get_keys(rtype, tagged, stype, otype):
             try:
                 rtags.update(self._tagdefs[key])
             except KeyError:
                 continue
         return rtags
-
-    def etype_rtags(self, etype, rtype, role, ttype='*'):
-        if role == 'subject':
-            return self.rtags(rtype, role, etype, ttype)
-        return self.rtags(rtype, role, ttype, etype)
-
-    def _get_keys(self, rtype, role, stype, otype):
-        assert role in ('subject', 'object'), role
-        keys = [(rtype, role, '*', '*'),
-                (rtype, role, '*', otype),
-                (rtype, role, stype, '*'),
-                (rtype, role, stype, otype)]
-        if stype == '*' or otype == '*':
-            keys.remove((rtype, role, '*', '*'))
-            if stype == '*':
-                keys.remove((rtype, role, '*', otype))
-            if otype == '*':
-                keys.remove((rtype, role, stype, '*'))
-        return keys
-
-    # dict compat
-    def __getitem__(self, key):
-        if isinstance(key, basestring):
-            key = (key,)
-        return self.rtags(*key)
-
-    __contains__ = __getitem__
--- a/test/unittest_rtags.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/test/unittest_rtags.py	Wed Apr 29 10:29:03 2009 +0200
@@ -1,19 +1,19 @@
 from logilab.common.testlib import TestCase, unittest_main
-from cubicweb.rtags import RelationTags
+from cubicweb.rtags import RelationTags, RelationTagsSet
 
 class RelationTagsTC(TestCase):
-    
+
     def test_rtags_expansion(self):
         rtags = RelationTags()
-        rtags.set_rtag('primary', 'travaille', 'subject', 'Societe')
-        rtags.set_rtag('secondary', 'evaluee', 'subject')
-        rtags.set_rtag('generated', 'tags', 'object')
-        self.assertEquals(rtags.rtag('evaluee', 'subject', 'Note'), 'secondary')
-        self.assertEquals(rtags.rtag('travaille', 'subject', 'Societe'), 'primary')
-        self.assertEquals(rtags.rtag('travaille', 'subject', 'Note'), None)
-        self.assertEquals(rtags.rtag('tags', 'subject', 'Note'), None)
-        self.assertEquals(rtags.rtag('tags', 'object', 'Note'), 'generated')
-        
+        rtags.tag_relation('primary', ('Societe', 'travaille', '*'), 'subject', )
+        rtags.tag_relation('secondary', ('*', 'evaluee', '*'), 'subject')
+        rtags.tag_relation('generated', ('*', 'tags', '*'), 'object')        
+        self.assertEquals(rtags.get('evaluee', 'subject', 'Note'), 'secondary')
+        self.assertEquals(rtags.get('travaille', 'subject', 'Societe'), 'primary')
+        self.assertEquals(rtags.get('travaille', 'subject', 'Note'), None)
+        self.assertEquals(rtags.get('tags', 'subject', 'Note'), None)
+        self.assertEquals(rtags.get('tags', 'object', 'Note'), 'generated')
+
 #         self.assertEquals(rtags.rtag('evaluee', 'Note', 'subject'), set(('secondary', 'link')))
 #         self.assertEquals(rtags.is_inlined('evaluee', 'Note', 'subject'), False)
 #         self.assertEquals(rtags.rtag('evaluee', 'Personne', 'subject'), set(('secondary', 'link')))
@@ -30,7 +30,16 @@
 #         self.assertEquals(rtags.rtag('evaluee', 'Note', 'subject'), set(('inlineview', 'link')))
 #         self.assertEquals(rtags.is_inlined('evaluee', 'Note', 'subject'), True)
 #         self.assertEquals(rtags.rtag('evaluee', 'Personne', 'subject'), set(('secondary', 'link')))
-#         self.assertEquals(rtags.is_inlined('evaluee', 'Personne', 'subject'), False)        
+#         self.assertEquals(rtags.is_inlined('evaluee', 'Personne', 'subject'), False)
+
+
+    def test_rtagset_expansion(self):
+        rtags = RelationTagsSet()
+        rtags.tag_relation('primary', ('Societe', 'travaille', '*'), 'subject', )
+        rtags.tag_relation('secondary', ('*', 'travaille', '*'), 'subject')
+        self.assertEquals(rtags.get('travaille', 'subject', 'Societe'), set(('primary', 'secondary')))
+        self.assertEquals(rtags.get('travaille', 'subject', 'Note'), set(('secondary',)))
+        self.assertEquals(rtags.get('tags', 'subject', 'Note'), set())
 
 if __name__ == '__main__':
     unittest_main()
--- a/web/test/unittest_views_editforms.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/test/unittest_views_editforms.py	Wed Apr 29 10:29:03 2009 +0200
@@ -9,13 +9,14 @@
 class AutomaticEntityFormTC(EnvBasedTC):
 
     def test_custom_widget(self):
-        AEF.rwidgets.set_rtag(AutoCompletionWidget, 'login', 'subject', 'CWUser')
+        AEF.rwidgets.tag_relation(AutoCompletionWidget,
+                                  ('CWUser', 'login', '*'), 'subject')
         form = self.vreg.select_object('forms', 'edition', self.request(), None,
                                        entity=self.user())
         field = form.field_by_name('login')
         self.assertIsInstance(field.widget, AutoCompletionWidget)
         AEF.rwidgets.del_rtag('login', 'subject', 'CWUser')
-        
+
 
     def test_euser_relations_by_category(self):
         #for (rtype, role, stype, otype), tag in AEF.rcategories._tagdefs.items():
@@ -41,7 +42,7 @@
                                ('modification_date', 'subject'),
                                ('owned_by', 'subject'),
                                ('bookmarked_by', 'object'),
-                               ])        
+                               ])
         self.assertListEquals(rbc(e, 'generic'),
                               [('primary_email', 'subject'),
                                ('use_email', 'subject'),
@@ -65,7 +66,7 @@
     def test_inlined_view(self):
         self.failUnless(AEF.rinlined.etype_rtag('CWUser', 'use_email', 'subject'))
         self.failIf(AEF.rinlined.etype_rtag('CWUser', 'primary_email', 'subject'))
-        
+
     def test_personne_relations_by_category(self):
         e = self.etype_instance('Personne')
         self.assertListEquals(rbc(e, 'primary'),
@@ -91,7 +92,7 @@
                                ('creation_date', 'subject'),
                                ('modification_date', 'subject'),
                                ('owned_by', 'subject'),
-                               ])        
+                               ])
         self.assertListEquals(rbc(e, 'generic'),
                               [('travaille', 'subject'),
                                ('connait', 'object')
@@ -103,7 +104,7 @@
                                ('is_instance_of', 'subject'),
                                ('identity', 'object'),
                                ])
-        
+
     def test_edition_form(self):
         rset = self.execute('CWUser X LIMIT 1')
         form = self.vreg.select_object('forms', 'edition', rset.req, rset,
@@ -112,41 +113,41 @@
         self.vreg.select_object('forms', 'edition', self.request(), None,
                                 entity=rset.get_entity(0, 0))
         self.failIf(any(f for f in form.fields if f is None))
-        
-        
+
+
 class FormViewsTC(WebTest):
     def test_delete_conf_formview(self):
         rset = self.execute('CWGroup X')
         self.view('deleteconf', rset, template=None).source
-        
+
     def test_automatic_edition_formview(self):
         rset = self.execute('CWUser X')
         self.view('edition', rset, row=0, template=None).source
-        
+
     def test_automatic_edition_formview(self):
         rset = self.execute('CWUser X')
         self.view('copy', rset, row=0, template=None).source
-        
+
     def test_automatic_creation_formview(self):
         self.view('creation', None, etype='CWUser', template=None).source
-        
+
     def test_automatic_muledit_formview(self):
         rset = self.execute('CWUser X')
         self.view('muledit', rset, template=None).source
-        
+
     def test_automatic_reledit_formview(self):
         rset = self.execute('CWUser X')
         self.view('reledit', rset, row=0, rtype='login', template=None).source
-        
+
     def test_automatic_inline_edit_formview(self):
         geid = self.execute('CWGroup X LIMIT 1')[0][0]
         rset = self.execute('CWUser X LIMIT 1')
         self.view('inline-edition', rset, row=0, rtype='in_group', peid=geid, template=None).source
-                              
+
     def test_automatic_inline_creation_formview(self):
         geid = self.execute('CWGroup X LIMIT 1')[0][0]
         self.view('inline-creation', None, etype='CWUser', rtype='in_group', peid=geid, template=None).source
 
-        
+
 if __name__ == '__main__':
     unittest_main()
--- a/web/uicfg.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/uicfg.py	Wed Apr 29 10:29:03 2009 +0200
@@ -9,32 +9,33 @@
 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
 """
 __docformat__ = "restructuredtext en"
-from cubicweb.rtags import RelationTags
+
+from cubicweb.rtags import RelationTags, RelationTagsSet
 
 # autoform.AutomaticEntityForm configuration ##################################
 
 # relations'category (eg primary/secondary/generic/metadata/generated)
 rcategories = RelationTags()
 # use primary and not generated for eid since it has to be an hidden
-rcategories.set_rtag('primary', 'eid', 'subject')
-rcategories.set_rtag('primary', 'in_state', 'subject')
-rcategories.set_rtag('secondary', 'description', 'subject')
-rcategories.set_rtag('metadata', 'creation_date', 'subject')
-rcategories.set_rtag('metadata', 'modification_date', 'subject')
-rcategories.set_rtag('metadata', 'owned_by', 'subject')
-rcategories.set_rtag('metadata', 'created_by', 'subject')
-rcategories.set_rtag('generated', 'has_text', 'subject')
-rcategories.set_rtag('generated', 'is', 'subject')
-rcategories.set_rtag('generated', 'is', 'object')
-rcategories.set_rtag('generated', 'is_instance_of', 'subject')
-rcategories.set_rtag('generated', 'is_instance_of', 'object')
-rcategories.set_rtag('generated', 'identity', 'subject')
-rcategories.set_rtag('generated', 'identity', 'object')
-rcategories.set_rtag('generated', 'require_permission', 'subject')
-rcategories.set_rtag('generated', 'wf_info_for', 'subject')
-rcategories.set_rtag('generated', 'wf_info_for', 'object')
-rcategories.set_rtag('generated', 'for_user', 'subject')
-rcategories.set_rtag('generated', 'for_user', 'object')
+rcategories.tag_relation('primary', ('*', 'eid', '*'), 'subject')
+rcategories.tag_relation('primary', ('*', 'in_state', '*'), 'subject')
+rcategories.tag_relation('secondary', ('*', 'description', '*'), 'subject')
+rcategories.tag_relation('metadata', ('*', 'creation_date', '*'), 'subject')
+rcategories.tag_relation('metadata', ('*', 'modification_date', '*'), 'subject')
+rcategories.tag_relation('metadata', ('*', 'owned_by', '*'), 'subject')
+rcategories.tag_relation('metadata', ('*', 'created_by', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'has_text', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'is', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'is', '*'), 'object')
+rcategories.tag_relation('generated', ('*', 'is_instance_of', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'is_instance_of', '*'), 'object')
+rcategories.tag_relation('generated', ('*', 'identity', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'identity', '*'), 'object')
+rcategories.tag_relation('generated', ('*', 'require_permission', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'wf_info_for', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'wf_info_for', '*'), 'object')
+rcategories.tag_relation('generated', ('*', 'for_user', '*'), 'subject')
+rcategories.tag_relation('generated', ('*', 'for_user', '*'), 'object')
 
 # relations'field class
 rfields = RelationTags()
@@ -50,21 +51,21 @@
 # set of tags of the form <action>_on_new on relations. <action> is a
 # schema action (add/update/delete/read), and when such a tag is found
 # permissions checking is by-passed and supposed to be ok
-rpermissions_overrides = RelationTags(use_set=True)
+rpermissions_overrides = RelationTagsSet()
 
 
 # boxes.EditBox configuration #################################################
 
 # 'link' / 'create' relation tags, used to control the "add entity" submenu
 rmode = RelationTags()
-rmode.set_rtag('link', 'is', 'subject')
-rmode.set_rtag('link', 'is', 'object')
-rmode.set_rtag('link', 'is_instance_of', 'subject')
-rmode.set_rtag('link', 'is_instance_of', 'object')
-rmode.set_rtag('link', 'identity', 'subject')
-rmode.set_rtag('link', 'identity', 'object')
-rmode.set_rtag('link', 'owned_by', 'subject')
-rmode.set_rtag('link', 'created_by', 'subject')
-rmode.set_rtag('link', 'require_permission', 'subject')
-rmode.set_rtag('link', 'wf_info_for', 'subject')
-rmode.set_rtag('link', 'wf_info_for', 'object')
+rmode.tag_relation('link', ('*', 'is', '*'), 'subject')
+rmode.tag_relation('link', ('*', 'is', '*'), 'object')
+rmode.tag_relation('link', ('*', 'is_instance_of', '*'), 'subject')
+rmode.tag_relation('link', ('*', 'is_instance_of', '*'), 'object')
+rmode.tag_relation('link', ('*', 'identity', '*'), 'subject')
+rmode.tag_relation('link', ('*', 'identity', '*'), 'object')
+rmode.tag_relation('link', ('*', 'owned_by', '*'), 'subject')
+rmode.tag_relation('link', ('*', 'created_by', '*'), 'subject')
+rmode.tag_relation('link', ('*', 'require_permission', '*'), 'subject')
+rmode.tag_relation('link', ('*', 'wf_info_for', '*'), 'subject')
+rmode.tag_relation('link', ('*', 'wf_info_for', '*'), 'object')
--- a/web/views/autoform.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/views/autoform.py	Wed Apr 29 10:29:03 2009 +0200
@@ -70,7 +70,7 @@
                             category = 'secondary'
                         else:
                             category = 'generic'
-                        cls.rcategories.set_rtag(category, rschema, role, X, Y)
+                        cls.rcategories.add_relation(category, (X, rschema, Y), role)
 
     @classmethod
     def erelations_by_category(cls, entity, categories=None, permission=None, rtags=None):
--- a/web/views/bookmark.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/views/bookmark.py	Wed Apr 29 10:29:03 2009 +0200
@@ -14,8 +14,8 @@
 from cubicweb.web import uicfg, action, box, formwidgets
 from cubicweb.web.views.baseviews import PrimaryView
 
-uicfg.rcategories.set_rtag('primary', 'path', 'subject', 'Bookmark')
-uicfg.rwidgets.set_rtag(formwidgets.TextInput, 'path', 'subject', 'Bookmark')
+uicfg.rcategories.tag_relation('primary', ('Bookmark', 'path', '*'), 'subject')
+uicfg.rwidgets.tag_relation(formwidgets.TextInput, ('Bookmark', 'path', '*'), 'subject')
 
 
 class FollowAction(action.Action):
--- a/web/views/boxes.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/views/boxes.py	Wed Apr 29 10:29:03 2009 +0200
@@ -64,7 +64,7 @@
                         else:
                             # link mode by default
                             mode = 'link'
-                        cls.rmode.set_rtag(mode, rschema, role, X, Y)
+                        cls.rmode.tag_relation(mode, (X, rschema, Y), role)
 
     @classmethod
     def relation_mode(cls, rtype, etype, targettype, role='subject'):
--- a/web/views/cwproperties.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/views/cwproperties.py	Wed Apr 29 10:29:03 2009 +0200
@@ -24,6 +24,9 @@
 
 _ = unicode
 
+uicfg.rfields.tag_relation(PropertyKeyField, ('CWProperty', 'pkey', '*'), 'subject')
+uicfg.rfields.tag_relation(PropertyValueField, ('CWProperty', 'value', '*'), 'subject')
+
 # some string we want to be internationalizable for nicer display of eproperty
 # groups
 _('navigation')
@@ -324,6 +327,3 @@
                 wdg.attrs.setdefault('size', 3)
         self.widget = wdg
 
-uicfg.rfields.set_rtag(PropertyKeyField, 'pkey', 'subject', 'CWProperty')
-uicfg.rfields.set_rtag(PropertyValueField, 'value', 'subject', 'CWProperty')
-
--- a/web/views/cwuser.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/views/cwuser.py	Wed Apr 29 10:29:03 2009 +0200
@@ -14,18 +14,18 @@
 from cubicweb.web.views.baseviews import PrimaryView
 
 
-uicfg.rcategories.set_rtag('secondary', 'firstname', 'subject', 'CWUser')
-uicfg.rcategories.set_rtag('secondary', 'surname', 'subject', 'CWUser')
-uicfg.rcategories.set_rtag('metadata', 'last_login_time', 'subject', 'CWUser')
-uicfg.rcategories.set_rtag('primary', 'in_group', 'subject', 'CWUser')
-uicfg.rcategories.set_rtag('generated', 'owned_by', 'object', otype='CWUser')
-uicfg.rcategories.set_rtag('generated', 'created_by', 'object', otype='CWUser')
-uicfg.rcategories.set_rtag('metadata', 'bookmarked_by', 'object', otype='CWUser')
-uicfg.rinlined.set_rtag(True, 'use_email', 'subject', 'CWUser')
-uicfg.rmode.set_rtag('create', 'in_group', 'object', otype='CWGroup')
-uicfg.rmode.set_rtag('link', 'owned_by', 'object', otype='CWUser')
-uicfg.rmode.set_rtag('link', 'created_by', 'object', otype='CWUser')
-uicfg.rmode.set_rtag('create', 'bookmarked_by', 'object', otype='CWUser')
+uicfg.rcategories.tag_relation('secondary', ('CWUser', 'firstname', '*'), 'subject')
+uicfg.rcategories.tag_relation('secondary', ('CWUser', 'surname', '*'), 'subject')
+uicfg.rcategories.tag_relation('metadata', ('CWUser', 'last_login_time', '*'), 'subject')
+uicfg.rcategories.tag_relation('primary', ('CWUser', 'in_group', '*'), 'subject')
+uicfg.rcategories.tag_relation('generated', ('*', 'owned_by', 'CWUser'), 'object')
+uicfg.rcategories.tag_relation('generated', ('*', 'created_by', 'CWUser'), 'object')
+uicfg.rcategories.tag_relation('metadata', ('*', 'bookmarked_by', 'CWUser'), 'object')
+uicfg.rinlined.tag_relation(True, ('CWUser', 'use_email', '*'), 'subject')
+uicfg.rmode.tag_relation('create', ('*', 'in_group', 'CWGroup'), 'object')
+uicfg.rmode.tag_relation('link', ('*', 'owned_by', 'CWUser'), 'object')
+uicfg.rmode.tag_relation('link', ('*', 'created_by', 'CWUser'), 'object')
+uicfg.rmode.tag_relation('create', ('*', 'bookmarked_by', 'CWUser'), 'object')
 
 
 class UserPreferencesEntityAction(action.Action):
--- a/web/views/schema.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/views/schema.py	Wed Apr 29 10:29:03 2009 +0200
@@ -19,19 +19,19 @@
 from cubicweb.web.views import TmpFileViewMixin, baseviews
 
 
-uicfg.rcategories.set_rtag('primary', 'require_group', 'subject', 'CWPermission')
-uicfg.rcategories.set_rtag('generated', 'final', 'subject', 'EEtype')
-uicfg.rcategories.set_rtag('generated', 'final', 'subject', 'ERtype')
-uicfg.rinlined.set_rtag(True, 'relation_type', 'subject', 'CWRelation')
-uicfg.rinlined.set_rtag(True, 'from_entity', 'subject', 'CWRelation')
-uicfg.rinlined.set_rtag(True, 'to_entity', 'subject', 'CWRelation')
-uicfg.rwidgets.set_rtag('StringWidget', 'expression', 'subject', 'RQLExpression')
+uicfg.rcategories.tag_relation('primary', ('CWPermission', 'require_group', '*'), 'subject')
+uicfg.rcategories.tag_relation('generated', ('EEtype', 'final', '*'), 'subject')
+uicfg.rcategories.tag_relation('generated', ('ERtype', 'final', '*'), 'subject')
+uicfg.rinlined.tag_relation(True, ('CWRelation', 'relation_type', '*'), 'subject')
+uicfg.rinlined.tag_relation(True, ('CWRelation', 'from_entity', '*'), 'subject')
+uicfg.rinlined.tag_relation(True, ('CWRelation', 'to_entity', '*'), 'subject')
+uicfg.rwidgets.tag_relation('StringWidget', ('RQLExpression', 'expression', '*'), 'subject')
 
-uicfg.rmode.set_rtag('create', 'state_of', 'object', otype='CWEType')
-uicfg.rmode.set_rtag('create', 'transition_of', 'object', otype='CWEType')
-uicfg.rmode.set_rtag('create', 'relation_type', 'object', otype='CWRType')
-uicfg.rmode.set_rtag('link', 'from_entity', 'object', otype='CWEType')
-uicfg.rmode.set_rtag('link', 'to_entity', 'object', otype='CWEType')
+uicfg.rmode.tag_relation('create', ('*', 'state_of', 'CWEType'), 'object')
+uicfg.rmode.tag_relation('create', ('*', 'transition_of', 'CWEType'), 'object')
+uicfg.rmode.tag_relation('create', ('*', 'relation_type', 'CWRType'), 'object')
+uicfg.rmode.tag_relation('link', ('*', 'from_entity', 'CWEType'), 'object')
+uicfg.rmode.tag_relation('link', ('*', 'to_entity', 'CWEType'), 'object')
 
 
 class ViewSchemaAction(action.Action):
--- a/web/views/workflow.py	Wed Apr 29 09:27:03 2009 +0200
+++ b/web/views/workflow.py	Wed Apr 29 10:29:03 2009 +0200
@@ -25,10 +25,10 @@
 
 _ = unicode
 
-EditBox.rmode.set_rtag('create', 'destination_state', 'subject', 'Transition')
-EditBox.rmode.set_rtag('create', 'allowed_transition', 'object', otype='Transition')
-EditBox.rmode.set_rtag('create', 'destination_state', 'object', otype='State')
-EditBox.rmode.set_rtag('create', 'allowed_transition', 'subject', 'State')
+EditBox.rmode.tag_relation('create', ('Transition', 'destination_state', '*'), 'subject')
+EditBox.rmode.tag_relation('create', ('*', 'allowed_transition', 'Transition'), 'object')
+EditBox.rmode.tag_relation('create', ('*', 'destination_state', 'State'), 'object')
+EditBox.rmode.tag_relation('create', ('State', 'allowed_transition', '*'), 'subject')
 
 
 # IWorkflowable views #########################################################