[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 19 Jan 2011 11:22:39 +0100
branchstable
changeset 6844 5ae2bc554c23
parent 6843 b70a26ca271c
child 6845 027c93dfba0a
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
cwconfig.py
etwist/twconfig.py
server/serverconfig.py
--- a/cwconfig.py	Wed Jan 19 10:13:31 2011 +0100
+++ b/cwconfig.py	Wed Jan 19 11:22:39 2011 +0100
@@ -159,14 +159,6 @@
 SMTP_LOCK = Lock()
 
 
-class metaconfiguration(type):
-    """metaclass to automaticaly register configuration"""
-    def __new__(mcs, name, bases, classdict):
-        cls = super(metaconfiguration, mcs).__new__(mcs, name, bases, classdict)
-        if classdict.get('name'):
-            CONFIGURATIONS.append(cls)
-        return cls
-
 def configuration_cls(name):
     """return the configuration class registered with the given name"""
     try:
@@ -290,7 +282,6 @@
 class CubicWebNoAppConfiguration(ConfigurationMixIn):
     """base class for cubicweb configuration without a specific instance directory
     """
-    __metaclass__ = metaconfiguration
     # to set in concrete configuration
     name = None
     # log messages format (see logging module documentation for available keys)
--- a/etwist/twconfig.py	Wed Jan 19 10:13:31 2011 +0100
+++ b/etwist/twconfig.py	Wed Jan 19 11:22:39 2011 +0100
@@ -23,7 +23,6 @@
 * the "all-in-one" configuration to get a web instance running in a twisted
   web server integrating a repository server in the same process (only available
   if the repository part of the software is installed
-
 """
 __docformat__ = "restructuredtext en"
 
@@ -31,8 +30,10 @@
 
 from logilab.common.configuration import Method
 
+from cubicweb.cwconfig import CONFIGURATIONS
 from cubicweb.web.webconfig import WebConfiguration, merge_options
 
+
 class TwistedConfiguration(WebConfiguration):
     """web instance (in a twisted web server) client of a RQL server"""
     name = 'twisted'
@@ -98,6 +99,9 @@
         from socket import gethostname
         return 'http://%s:%s/' % (self['host'] or gethostname(), self['port'] or 8080)
 
+
+CONFIGURATIONS.append(TwistedConfiguration)
+
 try:
     from cubicweb.server.serverconfig import ServerConfiguration
 
@@ -114,5 +118,8 @@
             """tell if pyro is activated for the in memory repository"""
             return self['pyro-server']
 
+
+    CONFIGURATIONS.append(AllInOneConfiguration)
+
 except ImportError:
     pass
--- a/server/serverconfig.py	Wed Jan 19 10:13:31 2011 +0100
+++ b/server/serverconfig.py	Wed Jan 19 11:22:39 2011 +0100
@@ -27,7 +27,7 @@
 from logilab.common.decorators import wproperty, cached
 
 from cubicweb.toolsutils import read_config, restrict_perms_to_user
-from cubicweb.cwconfig import CubicWebConfiguration, merge_options
+from cubicweb.cwconfig import CONFIGURATIONS, CubicWebConfiguration, merge_options
 from cubicweb.server import SOURCE_TYPES
 
 
@@ -346,3 +346,6 @@
         return ServerMigrationHelper(self, schema, interactive=interactive,
                                      cnx=cnx, repo=repo, connect=connect,
                                      verbosity=verbosity)
+
+
+CONFIGURATIONS.append(ServerConfiguration)