def updateSettings(self, section=None): if section != "usertrack": # Everything but usertrack requires authentication... apikey = AuthenticatedBaseHandler.extractAuthHeader() authResult = AuthenticatedBaseHandler.compareAuthorization(apikey) if authResult is False: AuthenticatedBaseHandler.raiseAuthFailure() dirty = False data = web.data() if data: sections = {} if section: sections = {section: utils.jsonDecode(data)} else: sections = utils.jsonDecode(data) config = HTMItAppConfig(mode=HTMItAppConfig.MODE_OVERRIDE_ONLY) for s in sections: if s in self.validSections(): for key in sections[s]: if not config.has_section(s): config.add_section(s) config.set(s, key, sections[s][key]) dirty = True else: return False if dirty: config.save() return dirty
def getAllSettings(self): # Make sure we have the latest version of configuration htm.it.app.config.loadConfig() apikey = AuthenticatedBaseHandler.extractAuthHeader() authResult = AuthenticatedBaseHandler.compareAuthorization(apikey) if authResult is False: AuthenticatedBaseHandler.raiseAuthFailure() res = {} for section in self.validSections(): res[section] = {} for key, value in htm.it.app.config.items(section): if key not in HIDDEN_SETTINGS.get(section, set()): res[section][key] = value return res
def getSectionSettings(self, section): # Make sure we have the latest version of configuration htm.it.app.config.loadConfig() res = {} if section != "usertrack": # Everything but usertrack requires authentication... apikey = AuthenticatedBaseHandler.extractAuthHeader() authResult = AuthenticatedBaseHandler.compareAuthorization(apikey) if authResult is False: AuthenticatedBaseHandler.raiseAuthFailure() if section in self.validSections(): for key, value in htm.it.app.config.items(section): if key not in HIDDEN_SETTINGS.get(section, set()): res[key] = value return res