def read_config(self, responsible, *args, **kwargs): self.config = MailConf.defaultConf() try: serialized = self.core.config_manager.get(self.NAME) except ConfigError: self.debug("Not configured, defaults loaded.") return config = MailConf.deserialize(serialized) valid, error = config.isValidWithMsg() if valid: self.config = config else: self.error( "Component %s read incorrect values. Message was: %s" % (self.NAME, error) )
def service_setMailConfig(self, context, serialized, message): config = MailConf.deserialize(serialized) if config.getReceivedSerialVersion() != 1: raise NuConfError( MAIL_BAD_CONFIGURATION, "Incompatible version: %s" % config.getReceivedSerialVersion() ) valid, error = config.isValidWithMsg() if not valid: raise NuConfError( MAIL_BAD_CONFIGURATION, "'%s' failed : '%s'" % (valid, error) ) self.config = config self.save_config(message, context) serialized = self.core.config_manager.get(self.NAME) defer = self.core.callService(context, 'CORE', 'hasComponent', 'antivirus') defer.addCallback(self._use_antivirus, context) defer.addErrback(self.writeError) return defer