cubicweb/server/sources/__init__.py
branch3.25
changeset 12143 a446124bcf3c
parent 12058 52ce05f7e9ee
child 12144 f54286c1cef5
equal deleted inserted replaced
12142:db2fc87348ab 12143:a446124bcf3c
    97         self.uri = source_config.pop('uri')
    97         self.uri = source_config.pop('uri')
    98         # unormalize to avoid non-ascii characters in logger's name, this will cause decoding error
    98         # unormalize to avoid non-ascii characters in logger's name, this will cause decoding error
    99         # on logging
    99         # on logging
   100         set_log_methods(self, getLogger('cubicweb.sources.' + unormalize(text_type(self.uri))))
   100         set_log_methods(self, getLogger('cubicweb.sources.' + unormalize(text_type(self.uri))))
   101         source_config.pop('type')
   101         source_config.pop('type')
   102         self.update_config(None, self.check_conf_dict(eid, source_config,
   102         self.config = self.check_conf_dict(
   103                                                       fail_if_unknown=False))
   103             eid, source_config, fail_if_unknown=False)
   104 
   104 
   105     def __repr__(self):
   105     def __repr__(self):
   106         return '<%s %s source %s @%#x>' % (self.uri, self.__class__.__name__,
   106         return '<%s %s source %s @%#x>' % (self.uri, self.__class__.__name__,
   107                                            self.eid, id(self))
   107                                            self.eid, id(self))
   108 
   108 
   174     def check_config(cls, source_entity):
   174     def check_config(cls, source_entity):
   175         """check configuration of source entity"""
   175         """check configuration of source entity"""
   176         return cls.check_conf_dict(source_entity.eid, source_entity.host_config,
   176         return cls.check_conf_dict(source_entity.eid, source_entity.host_config,
   177                                     _=source_entity._cw._)
   177                                     _=source_entity._cw._)
   178 
   178 
   179     def update_config(self, source_entity, typedconfig):
       
   180         """update configuration from source entity. `typedconfig` is config
       
   181         properly typed with defaults set
       
   182         """
       
   183         if source_entity is not None:
       
   184             self._entity_update(source_entity)
       
   185         self.config = typedconfig
       
   186 
       
   187     def _entity_update(self, source_entity):
   179     def _entity_update(self, source_entity):
   188         source_entity.complete()
   180         source_entity.complete()
   189         if source_entity.url:
   181         if source_entity.url:
   190             self.urls = [url.strip() for url in source_entity.url.splitlines()
   182             self.urls = [url.strip() for url in source_entity.url.splitlines()
   191                          if url.strip()]
   183                          if url.strip()]