for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 08 Apr 2009 11:33:12 +0200
branchtls-sprint
changeset 1285 d5ce82d65c2b
parent 1284 63ed4f4ff38d
child 1286 cb68c8af3858
for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
web/uicfg.py
web/views/boxes.py
web/views/editforms.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/uicfg.py	Wed Apr 08 11:33:12 2009 +0200
@@ -0,0 +1,67 @@
+"""schema driven ui configuration.
+
+set of properties configuring edition, actions box, ... rendering using tags
+on schema relations. Those properties are defined here so we don't get module
+reloading problems.
+
+:organization: Logilab
+:copyright: 2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
+"""
+__docformat__ = "restructuredtext en"
+from cubicweb.rtags import RelationTags
+
+# editforms.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')
+
+# relations'widget (eg one of available class name in cubicweb.web.formwidgets)
+rwidgets = RelationTags()
+
+# inlined view flag for non final relations: when True for an entry, the
+# entity(ies) at the other end of the relation will be editable from the
+# form of the edited entity
+rinlined = RelationTags()
+
+# 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)
+
+
+# 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', 'subject')
--- a/web/views/boxes.py	Wed Apr 08 11:30:57 2009 +0200
+++ b/web/views/boxes.py	Wed Apr 08 11:33:12 2009 +0200
@@ -20,6 +20,7 @@
 from cubicweb.selectors import match_user_groups, non_final_entity
 from cubicweb.web.htmlwidgets import BoxWidget, BoxMenu, BoxHtml, RawBoxItem
 from cubicweb.view import EntityView
+from cubicweb.web import uicfg
 from cubicweb.web.box import BoxTemplate
 
 _ = unicode
@@ -34,29 +35,12 @@
 
     title = _('actions')
     order = 2
-    # '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', 'subject')
-
-    @classmethod
-    def registered(cls, registry):
-        """build class using descriptor at registration time"""
-        super(EditBox, cls).registered(registry)
-        cls.init_rtags_mode()
-        return cls
+    # class attributes below are actually stored in the uicfg module since we
+    # don't want them to be reloaded
+    rmode = uicfg.rmode
         
     @classmethod
-    def init_rtags_mode(cls):
+    def vreg_initialization_completed(cls):
         """set default category tags for relations where it's not yet defined in
         the category relation tags
         """
--- a/web/views/editforms.py	Wed Apr 08 11:30:57 2009 +0200
+++ b/web/views/editforms.py	Wed Apr 08 11:33:12 2009 +0200
@@ -17,11 +17,10 @@
 from cubicweb import typed_eid
 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity,
                                 specified_etype_implements, yes)
-from cubicweb.rtags import RelationTags
 from cubicweb.utils import make_uid
 from cubicweb.view import EntityView
 from cubicweb.common import tags
-from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, formwidgets
+from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, formwidgets, uicfg
 from cubicweb.web.form import (FieldNotFound, CompositeForm, EntityFieldsForm,
                                FormMixIn)
 from cubicweb.web.formfields import guess_field
@@ -149,48 +148,15 @@
     cssclass = 'entityForm'
     copy_nav_params = True
     attrcategories = ('primary', 'secondary')
-    
-    # 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('metadata', 'creation_date', 'subject')
-    rcategories.set_rtag('metadata', 'modification_date', 'subject')
-    rcategories.set_rtag('generated', 'has_text', 'subject')
-    rcategories.set_rtag('metadata', 'owned_by', 'subject')
-    rcategories.set_rtag('metadata', 'created_by', '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('primary', 'in_state', 'subject')
-    rcategories.set_rtag('generated', 'wf_info_for', 'subject')
-    rcategories.set_rtag('generated', 'wf_info_for', 'subject')
-    rcategories.set_rtag('secondary', 'description', 'subject')
-
-    # relations'widget (eg one of available class name in cubicweb.web.formwidgets)
-    rwidgets = RelationTags()
-    # inlined view flag for non final relations: when True for an entry, the
-    # entity(ies) at the other end of the relation will be editable from the
-    # form of the edited entity
-    rinlined = RelationTags()
-    # 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)
-
-    @classmethod
-    def registered(cls, registry):
-        """build class using descriptor at registration time"""
-        super(AutomaticEntityForm, cls).registered(registry)
-        cls.init_rcategories()
-        return cls
+    # class attributes below are actually stored in the uicfg module since we
+    # don't want them to be reloaded
+    rcategories = uicfg.rcategories
+    rwidgets = uicfg.rwidgets
+    rinlined = uicfg.rinlined
+    rpermissions_overrides = uicfg.rpermissions_overrides
         
     @classmethod
-    def init_rcategories(cls):
+    def vreg_initialization_completed(cls):
         """set default category tags for relations where it's not yet defined in
         the category relation tags
         """