cubicweb/server/sources/__init__.py
branch3.25
changeset 12156 0d1d22a3a48b
parent 12155 4ba8fd2cd41a
child 12567 26744ad37953
equal deleted inserted replaced
12155:4ba8fd2cd41a 12156:0d1d22a3a48b
    83     # source configuration options
    83     # source configuration options
    84     options = ()
    84     options = ()
    85 
    85 
    86     # these are overridden by set_log_methods below
    86     # these are overridden by set_log_methods below
    87     # only defining here to prevent pylint from complaining
    87     # only defining here to prevent pylint from complaining
    88     info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
    88     info = warning = error = critical = exception = debug = lambda msg, *a, **kw: None
    89 
    89 
    90     def __init__(self, repo, source_config, eid=None):
    90     def __init__(self, repo, source_config, eid=None):
    91         self.repo = repo
    91         self.repo = repo
    92         self.set_schema(repo.schema)
    92         self.set_schema(repo.schema)
    93         self.eid = eid
    93         self.eid = eid
   211             self.urls = self.check_urls(source_entity)
   211             self.urls = self.check_urls(source_entity)
   212         else:
   212         else:
   213             self.urls = []
   213             self.urls = []
   214 
   214 
   215     PUBLIC_KEYS = ('type', 'uri', 'use-cwuri-as-url')
   215     PUBLIC_KEYS = ('type', 'uri', 'use-cwuri-as-url')
       
   216 
   216     def remove_sensitive_information(self, sourcedef):
   217     def remove_sensitive_information(self, sourcedef):
   217         """remove sensitive information such as login / password from source
   218         """remove sensitive information such as login / password from source
   218         definition
   219         definition
   219         """
   220         """
   220         for key in list(sourcedef):
   221         for key in list(sourcedef):
   221             if not key in self.PUBLIC_KEYS:
   222             if key not in self.PUBLIC_KEYS:
   222                 sourcedef.pop(key)
   223                 sourcedef.pop(key)
   223 
   224 
   224     # connections handling #####################################################
   225     # connections handling #####################################################
   225 
   226 
   226     def get_connection(self):
   227     def get_connection(self):
   280 
   281 
   281     def add_relation(self, cnx, subject, rtype, object):
   282     def add_relation(self, cnx, subject, rtype, object):
   282         """add a relation to the source"""
   283         """add a relation to the source"""
   283         raise NotImplementedError(self)
   284         raise NotImplementedError(self)
   284 
   285 
   285     def add_relations(self, cnx,  rtype, subj_obj_list):
   286     def add_relations(self, cnx, rtype, subj_obj_list):
   286         """add a relations to the source"""
   287         """add a relations to the source"""
   287         # override in derived classes if you feel you can
   288         # override in derived classes if you feel you can
   288         # optimize
   289         # optimize
   289         for subject, object in subj_obj_list:
   290         for subject, object in subj_obj_list:
   290             self.add_relation(cnx, subject, rtype, object)
   291             self.add_relation(cnx, subject, rtype, object)