cwconfig.py
changeset 2476 1294a6bdf3bf
parent 2473 490f88fb99b6
child 2613 5e19c2bb370e
--- a/cwconfig.py	Fri Jul 24 13:50:59 2009 +0200
+++ b/cwconfig.py	Fri Jul 24 14:33:37 2009 +0200
@@ -22,6 +22,7 @@
 from os.path import exists, join, expanduser, abspath, normpath, basename, isdir
 
 from logilab.common.decorators import cached
+from logilab.common.deprecation import deprecated_function
 from logilab.common.logging_ext import set_log_methods, init_log
 from logilab.common.configuration import (Configuration, Method,
                                           ConfigurationMixIn, merge_options)
@@ -221,7 +222,7 @@
           'group': 'appobjects', 'inputlevel': 2,
           }),
         )
-    # static and class methods used to get application independant resources ##
+    # static and class methods used to get instance independant resources ##
 
     @staticmethod
     def cubicweb_version():
@@ -247,7 +248,7 @@
 
     @classmethod
     def i18n_lib_dir(cls):
-        """return application's i18n directory"""
+        """return instance's i18n directory"""
         if cls.mode in ('dev', 'test') and not os.environ.get('APYCOT_ROOT'):
             return join(CW_SOFTWARE_ROOT, 'i18n')
         return join(cls.shared_dir(), 'i18n')
@@ -424,7 +425,7 @@
     @classmethod
     def build_vregistry_path(cls, templpath, evobjpath=None, tvobjpath=None):
         """given a list of directories, return a list of sub files and
-        directories that should be loaded by the application objects registry.
+        directories that should be loaded by the instance objects registry.
 
         :param evobjpath:
           optional list of sub-directories (or files without the .py ext) of
@@ -539,7 +540,7 @@
 
     # for some commands (creation...) we don't want to initialize gettext
     set_language = True
-    # set this to true to avoid false error message while creating an application
+    # set this to true to avoid false error message while creating an instance
     creating = False
     # set this to true to allow somethings which would'nt be possible
     repairing = False
@@ -566,7 +567,7 @@
           }),
         ('sender-name',
          {'type' : 'string',
-          'default': Method('default_application_id'),
+          'default': Method('default_instance_id'),
           'help': 'name used as HELO name for outgoing emails from the \
 repository.',
           'group': 'email', 'inputlevel': 2,
@@ -604,28 +605,28 @@
 
     @classmethod
     def config_for(cls, appid, config=None):
-        """return a configuration instance for the given application identifier
+        """return a configuration instance for the given instance identifier
         """
-        config = config or guess_configuration(cls.application_home(appid))
+        config = config or guess_configuration(cls.instance_home(appid))
         configcls = configuration_cls(config)
         return configcls(appid)
 
     @classmethod
     def possible_configurations(cls, appid):
         """return the name of possible configurations for the given
-        application id
+        instance id
         """
-        home = cls.application_home(appid)
+        home = cls.instance_home(appid)
         return possible_configurations(home)
 
     @classmethod
-    def application_home(cls, appid):
-        """return the home directory of the application with the given
-        application id
+    def instance_home(cls, appid):
+        """return the home directory of the instance with the given
+        instance id
         """
         home = join(cls.registry_dir(), appid)
         if not exists(home):
-            raise ConfigurationError('no such application %s (check it exists with "cubicweb-ctl list")' % appid)
+            raise ConfigurationError('no such instance %s (check it exists with "cubicweb-ctl list")' % appid)
         return home
 
     MODES = ('common', 'repository', 'Any', 'web')
@@ -639,14 +640,14 @@
 
     # default configuration methods ###########################################
 
-    def default_application_id(self):
-        """return the application identifier, useful for option which need this
+    def default_instance_id(self):
+        """return the instance identifier, useful for option which need this
         as default value
         """
         return self.appid
 
     def default_log_file(self):
-        """return default path to the log file of the application'server"""
+        """return default path to the log file of the instance'server"""
         if self.mode == 'dev':
             basepath = '/tmp/%s-%s' % (basename(self.appid), self.name)
             path = basepath + '.log'
@@ -662,10 +663,10 @@
         return '/var/log/cubicweb/%s-%s.log' % (self.appid, self.name)
 
     def default_pid_file(self):
-        """return default path to the pid file of the application'server"""
+        """return default path to the pid file of the instance'server"""
         return join(self.runtime_dir(), '%s-%s.pid' % (self.appid, self.name))
 
-    # instance methods used to get application specific resources #############
+    # instance methods used to get instance specific resources #############
 
     def __init__(self, appid):
         self.appid = appid
@@ -724,7 +725,7 @@
         self._cubes = self.reorder_cubes(list(self._cubes) + cubes)
 
     def main_config_file(self):
-        """return application's control configuration file"""
+        """return instance's control configuration file"""
         return join(self.apphome, '%s.conf' % self.name)
 
     def save(self):
@@ -741,7 +742,7 @@
         return md5.new(';'.join(infos)).hexdigest()
 
     def load_site_cubicweb(self):
-        """load (web?) application's specific site_cubicweb file"""
+        """load instance's specific site_cubicweb file"""
         for path in reversed([self.apphome] + self.cubes_path()):
             sitefile = join(path, 'site_cubicweb.py')
             if exists(sitefile) and not sitefile in self._site_loaded:
@@ -764,7 +765,7 @@
             self.load_defaults()
 
     def load_configuration(self):
-        """load application's configuration files"""
+        """load instance's configuration files"""
         super(CubicWebConfiguration, self).load_configuration()
         if self.apphome and self.set_language:
             # init gettext
@@ -783,7 +784,7 @@
             logging.fileConfig(logconfig)
 
     def available_languages(self, *args):
-        """return available translation for an application, by looking for
+        """return available translation for an instance, by looking for
         compiled catalog
 
         take *args to be usable as a vocabulary method
@@ -863,6 +864,6 @@
 
 set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration'))
 
-# alias to get a configuration instance from an application id
-application_configuration = CubicWebConfiguration.config_for
-
+# alias to get a configuration instance from an instance id
+instance_configuration = CubicWebConfiguration.config_for
+application_configuration = deprecated_function(instance_configuration, 'use instance_configuration')