Commit 7713b91e authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[sources] Stop translating validation error

this should be done later in the web ui, where lang is properly set.

--HG--
branch : 3.25
parent 79160d54662e
......@@ -29,7 +29,7 @@ from logilab.common.textutils import unormalize
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 @@ class AbstractSource(object):
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 @@ class AbstractSource(object):
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 @@ class AbstractSource(object):
# 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 @@ class AbstractSource(object):
@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 #####################################
......
......@@ -34,7 +34,7 @@ from lxml import etree
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 @@ class DataFeedSource(AbstractSource):
"""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
......
......@@ -41,7 +41,7 @@ from yams.schema import role_name
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 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment