def post_configure(self, core): log.sessions.info("Initializing Session Storage..") rex = re.compile(r"^(\w+)\+(.*)$") self.sessmans = [] for uri in Settings.sessions.storage_uris: match = rex.match(uri) if match: managerId = match.group(1) uri = match.group(2) spellName = "tornado_session_backend_%s" % managerId spell = SpellByStr(spellName) if spell: self.sessmans.append(spell.instantiate_backend(uri)) else: raise Exception("Session backend improperly configured, spell '%s' not found" % spellName) else: raise Exception("Incorrect session storage URI")
def post_configure(self, core): Settings.save = self.save log.core.debug('Settings.save method overriden') storageUri = Settings.core.settings_storage_uri recovery = Settings.recovery or Settings.core.recovery self.backend = None if not recovery: log.settings.info("Initializing Settings Storage..") rex = re.compile(r"^(\w+)\+(.*)$") match = rex.match(storageUri) if match: backendId = match.group(1) uri = match.group(2) spellName = "agatsuma_settings_backend_%s" % backendId spell = SpellByStr(spellName) if spell: self.backend = spell.instantiate_backend(uri) else: raise Exception("Settings backend improperly configured: spell '%s' not found" % spellName) else: raise Exception("Incorrect settings storage URI") else: log.settings.warning("Running in recovery mode, settings in storage are ignored") if self.backend: log.settings.info("Updating writable settings from storage '%s'..." % self.backend.__class__.__name__) updated = 0 for groupName in Settings.settings: group = Settings.settings[groupName] newGroup = copy.deepcopy(group) updatedInGroup = 0 for setting in group: if not setting in Settings.readonly_settings[groupName]: curVal = group[setting] newVal = self.backend.get("%s.%s" % (groupName, setting), curVal) if newVal != curVal: newGroup[setting] = newVal updated += 1 updatedInGroup += 1 if updatedInGroup: Settings.settings[groupName] = newGroup if updated: Settings.set_config_data(Settings.settings) log.settings.info("Settings updated from storage: %d" % updated)