equal
deleted
inserted
replaced
15 # |
15 # |
16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """cubicweb server sources support""" |
18 """cubicweb server sources support""" |
19 |
19 |
20 from __future__ import print_function |
|
21 |
|
22 from time import time |
20 from time import time |
23 from logging import getLogger |
21 from logging import getLogger |
24 |
|
25 from six import text_type |
|
26 |
22 |
27 from logilab.common import configuration |
23 from logilab.common import configuration |
28 from logilab.common.textutils import unormalize |
24 from logilab.common.textutils import unormalize |
29 |
25 |
30 from yams.schema import role_name |
26 from yams.schema import role_name |
95 self.public_config['use-cwuri-as-url'] = self.use_cwuri_as_url |
91 self.public_config['use-cwuri-as-url'] = self.use_cwuri_as_url |
96 self.remove_sensitive_information(self.public_config) |
92 self.remove_sensitive_information(self.public_config) |
97 self.uri = source_config.pop('uri') |
93 self.uri = source_config.pop('uri') |
98 # unormalize to avoid non-ascii characters in logger's name, this will cause decoding error |
94 # unormalize to avoid non-ascii characters in logger's name, this will cause decoding error |
99 # on logging |
95 # on logging |
100 set_log_methods(self, getLogger('cubicweb.sources.' + unormalize(text_type(self.uri)))) |
96 set_log_methods(self, getLogger('cubicweb.sources.' + unormalize(self.uri))) |
101 source_config.pop('type') |
97 source_config.pop('type') |
102 self.config = self._check_config_dict( |
98 self.config = self._check_config_dict( |
103 eid, source_config, raise_on_error=False) |
99 eid, source_config, raise_on_error=False) |
104 |
100 |
105 def __repr__(self): |
101 def __repr__(self): |
153 try: |
149 try: |
154 value = configuration._validate(value, optdict, optname) |
150 value = configuration._validate(value, optdict, optname) |
155 except Exception as ex: |
151 except Exception as ex: |
156 if not raise_on_error: |
152 if not raise_on_error: |
157 continue |
153 continue |
158 msg = text_type(ex) |
154 msg = str(ex) |
159 raise ValidationError(eid, {role_name('config', 'subject'): msg}) |
155 raise ValidationError(eid, {role_name('config', 'subject'): msg}) |
160 processed[optname] = value |
156 processed[optname] = value |
161 # cw < 3.10 bw compat |
157 # cw < 3.10 bw compat |
162 try: |
158 try: |
163 processed['adapter'] = confdict['adapter'] |
159 processed['adapter'] = confdict['adapter'] |