def write(self, data): ''' Writes a dict to the config file. :param data: dict of Section with nested dict of keys and values: {'Section': {'key': 'val', 'key2': 'val2'}, 'Section2': {'key': 'val'}} MUST contain fully populated sections or data will be lost. Only modifies supplied section. After updating config file, copies to core.CONFIG via self.stash() Does not return. ''' diff = Comparisons.compare_dict(data, core.CONFIG) core.CONFIG.update(data) with open(self.file, 'w') as f: json.dump(core.CONFIG, f, indent=4, sort_keys=True) self.stash(config=core.CONFIG) if diff: self.restart_scheduler(diff) l = diff.get('Server', {}).get('language') if l: localization.install(l) return
def __init__(self): self.auth = AuthController() self.postprocessing = Postprocessing() self.api = api.API() if core.CONFIG['Server']['authrequired']: self._cp_config = { 'auth.require': [] } self.ajax = ajax.Ajax() localization.get() localization.install() # point server toward custom 404 cherrypy.config.update({ 'error_page.404': self.error_page_404 }) # Lock down settings if required if core.CONFIG['Server']['adminrequired']: self.settings._cp_config['auth.require'] = [core.auth.is_admin] if core.CONFIG['Server']['checkupdates']: scheduler.AutoUpdateCheck.update_check(install=False)
def __init__(self): if core.CONFIG['Server']['authrequired']: self._cp_config = {'auth.require': []} self.ajax = ajax.Ajax() localization.get() localization.install() # point server toward custom 404 cherrypy.config.update({'error_page.404': self.error_page_404}) if core.CONFIG['Server']['checkupdates']: scheduler.AutoUpdateCheck.update_check(install=False)