# HG changeset patch # User Sylvain Thénault # Date 1492004312 -7200 # Node ID 649100470733ff0209b3499cb85b2722b6e47979 # Parent 79160d54662ebf49a5acd3080f1b6f7ddeed29fa [sources] Stop translating validation error this should be done later in the web ui, where lang is properly set. diff -r 79160d54662e -r 649100470733 cubicweb/server/sources/__init__.py --- a/cubicweb/server/sources/__init__.py Wed Apr 12 15:49:05 2017 +0200 +++ b/cubicweb/server/sources/__init__.py Wed Apr 12 15:38:32 2017 +0200 @@ -29,7 +29,7 @@ from yams.schema import role_name -from cubicweb import ValidationError, set_log_methods, server +from cubicweb import ValidationError, set_log_methods, server, _ from cubicweb.server import SOURCE_TYPES @@ -133,7 +133,7 @@ pass @classmethod - def check_conf_dict(cls, eid, confdict, _=text_type, fail_if_unknown=True): + def check_conf_dict(cls, eid, confdict, fail_if_unknown=True): """check configuration of source entity. Return config dict properly typed with defaults set. """ @@ -143,14 +143,15 @@ if value is configuration.REQUIRED: if not fail_if_unknown: continue - msg = _('specifying %s is mandatory' % optname) - raise ValidationError(eid, {role_name('config', 'subject'): msg}) + msg = _('specifying %s is mandatory') + msgargs = optname + raise ValidationError(eid, {role_name('config', 'subject'): msg}, msgargs) elif value is not None: # type check try: value = configuration._validate(value, optdict, optname) except Exception as ex: - msg = text_type(ex) # XXX internationalization + msg = text_type(ex) raise ValidationError(eid, {role_name('config', 'subject'): msg}) processed[optname] = value # cw < 3.10 bw compat @@ -161,8 +162,9 @@ # check for unknown options if confdict and tuple(confdict) != ('adapter',): if fail_if_unknown: - msg = _('unknown options %s') % ', '.join(confdict) - raise ValidationError(eid, {role_name('config', 'subject'): msg}) + msg = _('unknown options %s') + msgargs = ', '.join(confdict) + raise ValidationError(eid, {role_name('config', 'subject'): msg}, msgargs) else: logger = getLogger('cubicweb.sources') logger.warning('unknown options %s', ', '.join(confdict)) @@ -173,8 +175,7 @@ @classmethod def check_config(cls, source_entity): """check configuration of source entity""" - return cls.check_conf_dict(source_entity.eid, source_entity.host_config, - _=source_entity._cw._) + return cls.check_conf_dict(source_entity.eid, source_entity.dictconfig) # source initialization / finalization ##################################### diff -r 79160d54662e -r 649100470733 cubicweb/server/sources/datafeed.py --- a/cubicweb/server/sources/datafeed.py Wed Apr 12 15:49:05 2017 +0200 +++ b/cubicweb/server/sources/datafeed.py Wed Apr 12 15:38:32 2017 +0200 @@ -34,7 +34,7 @@ from logilab.common.deprecation import deprecated -from cubicweb import ObjectNotFound, ValidationError, SourceException +from cubicweb import ObjectNotFound, ValidationError, SourceException, _ from cubicweb.server.sources import AbstractSource from cubicweb.appobject import AppObject @@ -102,7 +102,6 @@ """check configuration of source entity""" typed_config = super(DataFeedSource, self).check_config(source_entity) if typed_config['synchronization-interval'] < 60: - _ = source_entity._cw._ msg = _('synchronization-interval must be greater than 1 minute') raise ValidationError(source_entity.eid, {'config': msg}) return typed_config diff -r 79160d54662e -r 649100470733 cubicweb/server/sources/native.py --- a/cubicweb/server/sources/native.py Wed Apr 12 15:49:05 2017 +0200 +++ b/cubicweb/server/sources/native.py Wed Apr 12 15:38:32 2017 +0200 @@ -41,7 +41,7 @@ from cubicweb import (UnknownEid, AuthenticationError, ValidationError, Binary, UniqueTogetherError, UndoTransactionException, ViolatedConstraint) -from cubicweb import transaction as tx, server, neg_role +from cubicweb import transaction as tx, server, neg_role, _ from cubicweb.utils import QueryCache from cubicweb.schema import VIRTUAL_RTYPES from cubicweb.cwconfig import CubicWebNoAppConfiguration @@ -352,8 +352,8 @@ def check_config(self, source_entity): """check configuration of source entity""" if source_entity.host_config: - msg = source_entity._cw._('the system source has its configuration ' - 'stored on the file-system') + msg = _('the system source has its configuration ' + 'stored on the file-system') raise ValidationError(source_entity.eid, {role_name('config', 'subject'): msg}) def add_authentifier(self, authentifier):