remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 13 Aug 2009 10:31:31 +0200
changeset 2803 870fa705dfde
parent 2802 2251b4aee54a
child 2804 0d01413ec9ae
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
web/uicfg.py
web/views/startup.py
--- a/web/uicfg.py	Thu Aug 13 10:24:51 2009 +0200
+++ b/web/uicfg.py	Thu Aug 13 10:31:31 2009 +0200
@@ -69,7 +69,7 @@
 
 from cubicweb import neg_role, onevent
 from cubicweb.rtags import (RelationTags, RelationTagsBool,
-                            RelationTagsSet, RelationTagsDict)
+                            RelationTagsSet, RelationTagsDict, register_rtag)
 from cubicweb.web import formwidgets
 
 
@@ -151,12 +151,25 @@
 # * 'schema'
 # * 'subobject' (not displayed by default)
 
-indexview_etype_section = {'EmailAddress': 'subobject',
-                           'CWUser': 'system',
-                           'CWGroup': 'system',
-                           'CWPermission': 'system',
-                           }
+class InitializableDict(dict):
+    def __init__(self, *args, **kwargs):
+        super(InitializableDict, self).__init__(*args, **kwargs)
+        register_rtag(self)
 
+    def init(schema, check=True):
+        for eschema in schema.entities():
+            if eschema.schema_entity():
+                uicfg.indexview_etype_section.setdefault(eschema, 'schema')
+            elif eschema.is_subobject(strict=True):
+                uicfg.indexview_etype_section.setdefault(eschema, 'subobject')
+            else:
+                uicfg.indexview_etype_section.setdefault(eschema, 'application')
+
+indexview_etype_section = InitializableDict(EmailAddress='subobject',
+                                            CWUser='system',
+                                            CWGroup='system',
+                                            CWPermission='system',
+                                            )
 
 # autoform.AutomaticEntityForm configuration ##################################
 
--- a/web/views/startup.py	Thu Aug 13 10:24:51 2009 +0200
+++ b/web/views/startup.py	Thu Aug 13 10:31:31 2009 +0200
@@ -22,16 +22,6 @@
     title = _('manage')
     http_cache_manager = httpcache.EtagHTTPCacheManager
 
-    @classmethod
-    def vreg_initialization_completed(cls):
-        for eschema in cls.schema.entities():
-            if eschema.schema_entity():
-                uicfg.indexview_etype_section.setdefault(eschema, 'schema')
-            elif eschema.is_subobject(strict=True):
-                uicfg.indexview_etype_section.setdefault(eschema, 'subobject')
-            else:
-                uicfg.indexview_etype_section.setdefault(eschema, 'application')
-
     def display_folders(self):
         return False