624 cls.warning('no __init__ file in cube %s', cube) |
624 cls.warning('no __init__ file in cube %s', cube) |
625 |
625 |
626 cubicweb_appobject_path = set(['entities']) |
626 cubicweb_appobject_path = set(['entities']) |
627 cube_appobject_path = set(['entities']) |
627 cube_appobject_path = set(['entities']) |
628 |
628 |
629 def __init__(self, debugmode=False): |
629 def __init__(self, debugmode=False, log_to_file=False): |
630 if debugmode: |
630 if debugmode: |
631 # in python 2.7, DeprecationWarning are not shown anymore by default |
631 # in python 2.7, DeprecationWarning are not shown anymore by default |
632 filterwarnings('default', category=DeprecationWarning) |
632 filterwarnings('default', category=DeprecationWarning) |
633 register_stored_procedures() |
633 register_stored_procedures() |
634 self._cubes = None |
634 self._cubes = None |
635 super(CubicWebNoAppConfiguration, self).__init__() |
635 super(CubicWebNoAppConfiguration, self).__init__() |
636 self.debugmode = debugmode |
636 self.debugmode = debugmode |
|
637 self.log_to_file = log_to_file |
637 self.adjust_sys_path() |
638 self.adjust_sys_path() |
638 self.load_defaults() |
639 self.load_defaults() |
639 # will be properly initialized later by _gettext_init |
640 # will be properly initialized later by _gettext_init |
640 self.translations = {'en': (str, lambda ctx, msgid: str(msgid) )} |
641 self.translations = {'en': (str, lambda ctx, msgid: str(msgid) )} |
641 self._site_loaded = set() |
642 self._site_loaded = set() |
662 logthreshold = self['log-threshold'] |
663 logthreshold = self['log-threshold'] |
663 if sys.platform == 'win32': |
664 if sys.platform == 'win32': |
664 # no logrotate on win32, so use logging rotation facilities |
665 # no logrotate on win32, so use logging rotation facilities |
665 # for now, hard code weekly rotation every sunday, and 52 weeks kept |
666 # for now, hard code weekly rotation every sunday, and 52 weeks kept |
666 # idea: make this configurable? |
667 # idea: make this configurable? |
667 init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format, |
668 init_log(not self.log_to_file, syslog, logthreshold, logfile, self.log_format, |
668 rotation_parameters={'when': 'W6', # every sunday |
669 rotation_parameters={'when': 'W6', # every sunday |
669 'interval': 1, |
670 'interval': 1, |
670 'backupCount': 52}) |
671 'backupCount': 52}) |
671 else: |
672 else: |
672 init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format) |
673 init_log(not self.log_to_file, syslog, logthreshold, logfile, self.log_format) |
673 # configure simpleTal logger |
674 # configure simpleTal logger |
674 logging.getLogger('simpleTAL').setLevel(logging.ERROR) |
675 logging.getLogger('simpleTAL').setLevel(logging.ERROR) |
675 |
676 |
676 def schema_modnames(self): |
677 def schema_modnames(self): |
677 modnames = [] |
678 modnames = [] |
880 mdir = join(dirname(__file__), 'misc', 'migration') |
881 mdir = join(dirname(__file__), 'misc', 'migration') |
881 assert exists(mdir), 'migration path %s does not exist' % mdir |
882 assert exists(mdir), 'migration path %s does not exist' % mdir |
882 return mdir |
883 return mdir |
883 |
884 |
884 @classmethod |
885 @classmethod |
885 def config_for(cls, appid, config=None, debugmode=False, creating=False): |
886 def config_for(cls, appid, config=None, debugmode=False, log_to_file=False, creating=False): |
886 """return a configuration instance for the given instance identifier |
887 """return a configuration instance for the given instance identifier |
887 """ |
888 """ |
888 cls.load_available_configs() |
889 cls.load_available_configs() |
889 config = config or guess_configuration(cls.instance_home(appid)) |
890 config = config or guess_configuration(cls.instance_home(appid)) |
890 configcls = configuration_cls(config) |
891 configcls = configuration_cls(config) |
891 return configcls(appid, debugmode, creating) |
892 return configcls(appid, debugmode, creating, log_to_file=log_to_file) |
892 |
893 |
893 @classmethod |
894 @classmethod |
894 def possible_configurations(cls, appid): |
895 def possible_configurations(cls, appid): |
895 """return the name of possible configurations for the given |
896 """return the name of possible configurations for the given |
896 instance id |
897 instance id |
979 repo.bootstrap() |
980 repo.bootstrap() |
980 return repo |
981 return repo |
981 |
982 |
982 # instance methods used to get instance specific resources ############# |
983 # instance methods used to get instance specific resources ############# |
983 |
984 |
984 def __init__(self, appid, debugmode=False, creating=False): |
985 def __init__(self, appid, debugmode=False, creating=False, log_to_file=False): |
985 self.appid = appid |
986 self.appid = appid |
986 # set to true while creating an instance |
987 # set to true while creating an instance |
987 self.creating = creating |
988 self.creating = creating |
988 super(CubicWebConfiguration, self).__init__(debugmode) |
989 super(CubicWebConfiguration, self).__init__(debugmode, |
|
990 log_to_file=log_to_file) |
989 fake_gettext = (str, lambda ctx, msgid: str(msgid)) |
991 fake_gettext = (str, lambda ctx, msgid: str(msgid)) |
990 for lang in self.available_languages(): |
992 for lang in self.available_languages(): |
991 self.translations[lang] = fake_gettext |
993 self.translations[lang] = fake_gettext |
992 self._cubes = None |
994 self._cubes = None |
993 self.load_file_configuration(self.main_config_file()) |
995 self.load_file_configuration(self.main_config_file()) |