256 'can_cross_relation', 'rel_type_sources'): |
256 'can_cross_relation', 'rel_type_sources'): |
257 clear_cache(self, cache) |
257 clear_cache(self, cache) |
258 |
258 |
259 def add_source(self, sourceent, add_to_pools=True): |
259 def add_source(self, sourceent, add_to_pools=True): |
260 source = self.get_source(sourceent.type, sourceent.name, |
260 source = self.get_source(sourceent.type, sourceent.name, |
261 sourceent.host_config) |
261 sourceent.host_config, sourceent.eid) |
262 source.eid = sourceent.eid |
|
263 self.sources_by_eid[sourceent.eid] = source |
262 self.sources_by_eid[sourceent.eid] = source |
264 self.sources_by_uri[sourceent.name] = source |
263 self.sources_by_uri[sourceent.name] = source |
265 if self.config.source_enabled(source): |
264 if self.config.source_enabled(source): |
266 source.init(True, session=sourceent._cw) |
265 source.init(True, session=sourceent._cw) |
267 self.sources.append(source) |
266 self.sources.append(source) |
281 self.querier.set_planner() |
280 self.querier.set_planner() |
282 for pool in self.pools: |
281 for pool in self.pools: |
283 pool.remove_source(source) |
282 pool.remove_source(source) |
284 self._clear_planning_caches() |
283 self._clear_planning_caches() |
285 |
284 |
286 def get_source(self, type, uri, source_config): |
285 def get_source(self, type, uri, source_config, eid=None): |
287 # set uri and type in source config so it's available through |
286 # set uri and type in source config so it's available through |
288 # source_defs() |
287 # source_defs() |
289 source_config['uri'] = uri |
288 source_config['uri'] = uri |
290 source_config['type'] = type |
289 source_config['type'] = type |
291 return sources.get_source(type, source_config, self) |
290 return sources.get_source(type, source_config, self, eid) |
292 |
291 |
293 def set_schema(self, schema, resetvreg=True, rebuildinfered=True): |
292 def set_schema(self, schema, resetvreg=True, rebuildinfered=True): |
294 if rebuildinfered: |
293 if rebuildinfered: |
295 schema.rebuild_infered_relations() |
294 schema.rebuild_infered_relations() |
296 self.info('set schema %s %#x', schema.name, id(schema)) |
295 self.info('set schema %s %#x', schema.name, id(schema)) |