291 name = None |
291 name = None |
292 # log messages format (see logging module documentation for available keys) |
292 # log messages format (see logging module documentation for available keys) |
293 log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s' |
293 log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s' |
294 # nor remove appobjects based on unused interface |
294 # nor remove appobjects based on unused interface |
295 cleanup_interface_sobjects = True |
295 cleanup_interface_sobjects = True |
296 # debug mode |
|
297 debugmode = False |
|
298 |
296 |
299 |
297 |
300 if (CWDEV and _forced_mode != 'system'): |
298 if (CWDEV and _forced_mode != 'system'): |
301 mode = 'user' |
299 mode = 'user' |
302 _CUBES_DIR = join(CW_SOFTWARE_ROOT, '../cubes') |
300 _CUBES_DIR = join(CW_SOFTWARE_ROOT, '../cubes') |
658 vregpath.append(path) |
656 vregpath.append(path) |
659 elif exists(path + '.py'): |
657 elif exists(path + '.py'): |
660 vregpath.append(path + '.py') |
658 vregpath.append(path + '.py') |
661 return vregpath |
659 return vregpath |
662 |
660 |
663 def __init__(self): |
661 def __init__(self, debugmode=False): |
664 register_stored_procedures() |
662 register_stored_procedures() |
665 ConfigurationMixIn.__init__(self) |
663 ConfigurationMixIn.__init__(self) |
|
664 self.debugmode = debugmode |
666 self.adjust_sys_path() |
665 self.adjust_sys_path() |
667 self.load_defaults() |
666 self.load_defaults() |
668 self.translations = {} |
667 self.translations = {} |
669 # don't register ReStructured Text directives by simple import, avoid pb |
668 # don't register ReStructured Text directives by simple import, avoid pb |
670 # with eg sphinx. |
669 # with eg sphinx. |
678 |
677 |
679 def adjust_sys_path(self): |
678 def adjust_sys_path(self): |
680 # overriden in CubicWebConfiguration |
679 # overriden in CubicWebConfiguration |
681 self.cls_adjust_sys_path() |
680 self.cls_adjust_sys_path() |
682 |
681 |
683 def init_log(self, logthreshold=None, debug=False, |
682 def init_log(self, logthreshold=None, logfile=None, syslog=False): |
684 logfile=None, syslog=False): |
|
685 """init the log service""" |
683 """init the log service""" |
686 if logthreshold is None: |
684 if logthreshold is None: |
687 if debug: |
685 if self.debugmode: |
688 logthreshold = 'DEBUG' |
686 logthreshold = 'DEBUG' |
689 else: |
687 else: |
690 logthreshold = self['log-threshold'] |
688 logthreshold = self['log-threshold'] |
691 self.debugmode = debug |
689 init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format) |
692 init_log(debug, syslog, logthreshold, logfile, self.log_format) |
|
693 # configure simpleTal logger |
690 # configure simpleTal logger |
694 logging.getLogger('simpleTAL').setLevel(logging.ERROR) |
691 logging.getLogger('simpleTAL').setLevel(logging.ERROR) |
695 |
692 |
696 def vregistry_path(self): |
693 def vregistry_path(self): |
697 """return a list of files or directories where the registry will look |
694 """return a list of files or directories where the registry will look |
801 if not exists(mdir): |
798 if not exists(mdir): |
802 raise ConfigurationError('migration path %s doesn\'t exist' % mdir) |
799 raise ConfigurationError('migration path %s doesn\'t exist' % mdir) |
803 return mdir |
800 return mdir |
804 |
801 |
805 @classmethod |
802 @classmethod |
806 def config_for(cls, appid, config=None): |
803 def config_for(cls, appid, config=None, debugmode=False): |
807 """return a configuration instance for the given instance identifier |
804 """return a configuration instance for the given instance identifier |
808 """ |
805 """ |
809 config = config or guess_configuration(cls.instance_home(appid)) |
806 config = config or guess_configuration(cls.instance_home(appid)) |
810 configcls = configuration_cls(config) |
807 configcls = configuration_cls(config) |
811 return configcls(appid) |
808 return configcls(appid, debugmode) |
812 |
809 |
813 @classmethod |
810 @classmethod |
814 def possible_configurations(cls, appid): |
811 def possible_configurations(cls, appid): |
815 """return the name of possible configurations for the given |
812 """return the name of possible configurations for the given |
816 instance id |
813 instance id |
874 rtdir = env_path('CW_RUNTIME_DIR', tempfile.gettempdir(), 'run time') |
871 rtdir = env_path('CW_RUNTIME_DIR', tempfile.gettempdir(), 'run time') |
875 return join(rtdir, '%s-%s.pid' % (self.appid, self.name)) |
872 return join(rtdir, '%s-%s.pid' % (self.appid, self.name)) |
876 |
873 |
877 # instance methods used to get instance specific resources ############# |
874 # instance methods used to get instance specific resources ############# |
878 |
875 |
879 def __init__(self, appid): |
876 def __init__(self, appid, debugmode=False): |
880 self.appid = appid |
877 self.appid = appid |
881 CubicWebNoAppConfiguration.__init__(self) |
878 CubicWebNoAppConfiguration.__init__(self, debugmode) |
882 self._cubes = None |
879 self._cubes = None |
883 self._site_loaded = set() |
880 self._site_loaded = set() |
884 self.load_file_configuration(self.main_config_file()) |
881 self.load_file_configuration(self.main_config_file()) |
885 |
882 |
886 def adjust_sys_path(self): |
883 def adjust_sys_path(self): |
988 super(CubicWebConfiguration, self).load_configuration() |
985 super(CubicWebConfiguration, self).load_configuration() |
989 if self.apphome and self.set_language: |
986 if self.apphome and self.set_language: |
990 # init gettext |
987 # init gettext |
991 self._set_language() |
988 self._set_language() |
992 |
989 |
993 def init_log(self, logthreshold=None, debug=False, force=False): |
990 def init_log(self, logthreshold=None, force=False): |
994 """init the log service""" |
991 """init the log service""" |
995 if not force and hasattr(self, '_logging_initialized'): |
992 if not force and hasattr(self, '_logging_initialized'): |
996 return |
993 return |
997 self._logging_initialized = True |
994 self._logging_initialized = True |
998 CubicWebNoAppConfiguration.init_log(self, logthreshold, debug, |
995 CubicWebNoAppConfiguration.init_log(self, logthreshold, |
999 logfile=self.get('log-file')) |
996 logfile=self.get('log-file')) |
1000 # read a config file if it exists |
997 # read a config file if it exists |
1001 logconfig = join(self.apphome, 'logging.conf') |
998 logconfig = join(self.apphome, 'logging.conf') |
1002 if exists(logconfig): |
999 if exists(logconfig): |
1003 logging.fileConfig(logconfig) |
1000 logging.fileConfig(logconfig) |