def __delitem__(self, key): ''' remove an item from the config :param key: the name of the ocnfig entry :type key: string :return : return the std value like the std dict does, whatever this is :rtype : any value a dict update will return ''' Key = key if 'linotp.' + key in self: Key = 'linotp.' + key elif key in self: Key = key res = super().__delitem__(Key) # sync with global dict self.glo.delConfig(Key) # sync with db if key.startswith('linotp.'): Key = key else: Key = 'linotp.' + key _removeConfigDB(Key) _storeConfigDB('linotp.Config', datetime.now()) return res
def __delitem__(self, key): ''' remove an item from the config :param key: the name of the ocnfig entry :type key: string :return : return the std value like the std dict does, whatever this is :rtype : any value a dict update will return ''' Key = key if self.parent.has_key(key): Key = key elif self.parent.has_key('linotp.' + key): Key = 'linotp.' + key res = self.parent.__delitem__(Key) # sync with global dict self.glo.delConfig(Key) # sync with db if key.startswith('linotp.'): Key = key else: Key = 'linotp.' + key _removeConfigDB(Key) _storeConfigDB('linotp.Config', datetime.now()) return res
def refreshConfig(self, do_reload=False): conf = self.glo.getConfig() if do_reload is True: # in case there is no entry in the dbconf or # the config file is newer, we write the config back to the db entries = conf.keys() for entry in entries: del conf[entry] writeback = False # get all conf entries from the config file fileconf = _getConfigFromEnv() # get all configs from the DB (dbconf, delay) = _retrieveAllConfigDB() self.glo.setConfigIncomplete(not delay) # we only merge the config file once as a removed entry # might reappear otherwise if 'linotp.Config' not in dbconf: conf.update(fileconf) writeback = True conf.update(dbconf) # check, if there is a selfTest in the DB and delete it if 'linotp.selfTest' in dbconf: _removeConfigDB('linotp.selfTest') _storeConfigDB('linotp.Config', datetime.now()) # the only thing we take from the fileconf is the selftest if 'linotp.selfTest' in fileconf: conf['linotp.selfTest'] = 'True' if writeback is True: for con in conf: if con != 'linotp.selfTest': _storeConfigDB(con, conf.get(con)) _storeConfigDB('linotp.Config', datetime.now()) self.glo.setConfig(conf, replace=True) self.parent.update(conf) return
def refreshConfig(self, do_reload=False): conf = self.glo.getConfig() if do_reload is True: # in case there is no entry in the dbconf or # the config file is newer, we write the config back to the db entries = conf.keys() for entry in entries: del conf[entry] writeback = False # get all conf entries from the config file fileconf = _getConfigFromEnv() # get all configs from the DB (dbconf, delay) = _retrieveAllConfigDB() self.glo.setConfigIncomplete(not delay) # we only merge the config file once as a removed entry # might reappear otherwise if 'linotp.Config' not in dbconf: conf.update(fileconf) writeback = True conf.update(dbconf) # check, if there is a selfTest in the DB and delete it if 'linotp.selfTest' in dbconf: _removeConfigDB('linotp.selfTest') _storeConfigDB('linotp.Config', datetime.now()) # the only thing we take from the fileconf is the selftest if 'linotp.selfTest' in fileconf: conf['linotp.selfTest'] = 'True' if writeback is True: for con in conf: if con != 'linotp.selfTest': _storeConfigDB(con, conf.get(con)) _storeConfigDB(u'linotp.Config', datetime.now()) self.glo.setConfig(conf, replace=True) self.parent.update(conf) return