simplify registry options to disable some appobjects to use a single option tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 11 Mar 2009 11:13:41 +0100
branchtls-sprint
changeset 1046 52ee022d87e3
parent 1045 5040a5835e4d
child 1047 21d4d5e6aa45
simplify registry options to disable some appobjects to use a single option
cwconfig.py
vregistry.py
--- a/cwconfig.py	Wed Mar 11 11:02:32 2009 +0100
+++ b/cwconfig.py	Wed Mar 11 11:13:41 2009 +0100
@@ -56,17 +56,6 @@
                                  % (directory, modes))
     return modes[0]
 
-# XXX generate this according to the configuration (repository/all-in-one/web)
-VREGOPTIONS = []
-for registry in ('etypes', 'hooks', 'controllers', 'actions', 'components',
-                 'views', 'boxes', 'contentnavigation', 'urlrewriting',
-                 'facets'):
-    VREGOPTIONS.append(('disable-%s'%registry,
-                        {'type' : 'csv', 'default': (),
-                         'help': 'list of identifier of application objects from the %s registry to disable'%registry,
-                         'group': 'appobjects', 'inputlevel': 2,
-                         }))
-VREGOPTIONS = tuple(VREGOPTIONS)
 
 # persistent options definition
 PERSISTENT_OPTIONS = (
@@ -157,7 +146,7 @@
         mode = 'installed'
         CUBES_DIR = '/usr/share/cubicweb/cubes/'
 
-    options = VREGOPTIONS + (
+    options = (
        ('log-threshold',
          {'type' : 'string', # XXX use a dedicated type?
           'default': 'ERROR',
@@ -202,6 +191,11 @@
 this option is set to yes",
           'group': 'email', 'inputlevel': 2,
           }),
+        ('disable-appobjects',
+         {'type' : 'csv', 'default': (),
+          'help': 'comma separated list of identifiers of application objects (<registry>.<oid>) to disable',
+          'group': 'appobjects', 'inputlevel': 2,
+          }),
         )
     # static and class methods used to get application independant resources ##
         
--- a/vregistry.py	Wed Mar 11 11:02:32 2009 +0100
+++ b/vregistry.py	Wed Mar 11 11:13:41 2009 +0100
@@ -474,7 +474,7 @@
             or not cls.__registry__ or not cls.id):
             return
         regname = cls.__registry__
-        if cls.id in self.config['disable-%s' % regname]:
+        if '%s.%s' % (regname, cls.id) in self.config['disable-appobjects']:
             return
         registry = self._registries.setdefault(regname, {})
         vobjects = registry.setdefault(cls.id, [])