cwconfig.py
branchstable
changeset 6844 5ae2bc554c23
parent 6799 30faf6021278
child 6846 4dd1df437e15
equal deleted inserted replaced
6843:b70a26ca271c 6844:5ae2bc554c23
   156 
   156 
   157 CONFIGURATIONS = []
   157 CONFIGURATIONS = []
   158 
   158 
   159 SMTP_LOCK = Lock()
   159 SMTP_LOCK = Lock()
   160 
   160 
   161 
       
   162 class metaconfiguration(type):
       
   163     """metaclass to automaticaly register configuration"""
       
   164     def __new__(mcs, name, bases, classdict):
       
   165         cls = super(metaconfiguration, mcs).__new__(mcs, name, bases, classdict)
       
   166         if classdict.get('name'):
       
   167             CONFIGURATIONS.append(cls)
       
   168         return cls
       
   169 
   161 
   170 def configuration_cls(name):
   162 def configuration_cls(name):
   171     """return the configuration class registered with the given name"""
   163     """return the configuration class registered with the given name"""
   172     try:
   164     try:
   173         return [c for c in CONFIGURATIONS if c.name == name][0]
   165         return [c for c in CONFIGURATIONS if c.name == name][0]
   288 _USR_INSTALL = _INSTALL_PREFIX == '/usr'
   280 _USR_INSTALL = _INSTALL_PREFIX == '/usr'
   289 
   281 
   290 class CubicWebNoAppConfiguration(ConfigurationMixIn):
   282 class CubicWebNoAppConfiguration(ConfigurationMixIn):
   291     """base class for cubicweb configuration without a specific instance directory
   283     """base class for cubicweb configuration without a specific instance directory
   292     """
   284     """
   293     __metaclass__ = metaconfiguration
       
   294     # to set in concrete configuration
   285     # to set in concrete configuration
   295     name = None
   286     name = None
   296     # log messages format (see logging module documentation for available keys)
   287     # log messages format (see logging module documentation for available keys)
   297     log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s'
   288     log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s'
   298     # the format below can be useful to debug multi thread issues:
   289     # the format below can be useful to debug multi thread issues: