fix rtags initialization: do it at the registry level to avoid multiple initialization of the same rtag tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 12 May 2009 18:15:49 +0200
branchtls-sprint
changeset 1752 4b0b912ff5b7
parent 1751 59e9a4f5bfea
child 1753 ba01605cdd9a
fix rtags initialization: do it at the registry level to avoid multiple initialization of the same rtag
cwvreg.py
rtags.py
web/views/autoform.py
web/views/boxes.py
web/views/primary.py
--- a/cwvreg.py	Tue May 12 18:14:46 2009 +0200
+++ b/cwvreg.py	Tue May 12 18:15:49 2009 +0200
@@ -114,13 +114,17 @@
         """overriden to remove objects requiring a missing interface"""
         if super(CubicWebRegistry, self).register_objects(path, force_reload):
             self.initialization_completed()
-            # print registry content
+            # call vreg_initialization_completed on appobjects and print
+            # registry content
             for registry, objects in self.items():
                 self.debug('available in registry %s: %s', registry,
                            sorted(objects))
                 for appobjects in objects.itervalues():
                     for appobject in appobjects:
                         appobject.vreg_initialization_completed()
+            from cubicweb.rtags import RTAGS
+            for rtag in RTAGS:
+                rtag.init(self.schema)
 
     def initialization_completed(self):
         # clear etype cache if you don't want to run into deep weirdness
--- a/rtags.py	Tue May 12 18:14:46 2009 +0200
+++ b/rtags.py	Tue May 12 18:15:49 2009 +0200
@@ -10,6 +10,9 @@
 
 from logilab.common.logging_ext import set_log_methods
 
+RTAGS = []
+def register_rtag(rtag):
+    RTAGS.append(rtag)
 
 class RelationTags(object):
     """a tag store for full relation definitions :
@@ -26,7 +29,8 @@
         if allowed_values is not None:
             self._allowed_values = allowed_values
         self._initfunc = initfunc
-
+        register_rtag(self)
+        
     def __repr__(self):
         return repr(self._tagdefs)
 
--- a/web/views/autoform.py	Tue May 12 18:14:46 2009 +0200
+++ b/web/views/autoform.py	Tue May 12 18:15:49 2009 +0200
@@ -45,17 +45,6 @@
     rpermissions_overrides = uicfg.autoform_permissions_overrides
 
     @classmethod
-    def vreg_initialization_completed(cls):
-        """set default category tags for relations where it's not yet defined in
-        the category relation tags
-        """
-        cls.rcategories.init(cls.schema)
-        cls.rfields.init(cls.schema)
-        cls.rwidgets.init(cls.schema)
-        cls.rinlined.init(cls.schema)
-        cls.rpermissions_overrides.init(cls.schema)
-
-    @classmethod
     def erelations_by_category(cls, entity, categories=None, permission=None,
                                rtags=None):
         """return a list of (relation schema, target schemas, role) matching
--- a/web/views/boxes.py	Tue May 12 18:14:46 2009 +0200
+++ b/web/views/boxes.py	Tue May 12 18:15:49 2009 +0200
@@ -39,13 +39,6 @@
     # don't want them to be reloaded
     appearsin_addmenu = uicfg.actionbox_appearsin_addmenu
 
-    @classmethod
-    def vreg_initialization_completed(cls):
-        """set default category tags for relations where it's not yet defined in
-        the category relation tags
-        """
-        cls.appearsin_addmenu.init(cls.schema)
-
     def call(self, view=None, **kwargs):
         _ = self.req._
         title = _(self.title)
--- a/web/views/primary.py	Tue May 12 18:14:46 2009 +0200
+++ b/web/views/primary.py	Tue May 12 18:15:49 2009 +0200
@@ -28,14 +28,6 @@
     display_ctrl = uicfg.primaryview_display_ctrl
     main_related_section = True
 
-    @classmethod
-    def vreg_initialization_completed(cls):
-        """set default category tags for relations where it's not yet defined in
-        the category relation tags
-        """
-        cls.rsection.init(cls.schema)
-        cls.display_ctrl.init(cls.schema)
-
     def html_headers(self):
         """return a list of html headers (eg something to be inserted between
         <head> and </head> of the returned page