cubicweb/server/repository.py
changeset 12057 90c40f229ab0
parent 12054 d830ea048c97
child 12060 0cdf5fafd234
equal deleted inserted replaced
12056:f223f98e3b14 12057:90c40f229ab0
   320                     self.sources_by_eid[sourceent.eid] = self.system_source
   320                     self.sources_by_eid[sourceent.eid] = self.system_source
   321                     self.system_source.init(True, sourceent)
   321                     self.system_source.init(True, sourceent)
   322                     continue
   322                     continue
   323                 self.add_source(sourceent)
   323                 self.add_source(sourceent)
   324 
   324 
   325     def _clear_planning_caches(self):
       
   326         clear_cache(self, 'source_defs')
       
   327 
       
   328     def add_source(self, sourceent):
   325     def add_source(self, sourceent):
   329         try:
   326         try:
   330             source = self.get_source(sourceent.type, sourceent.name,
   327             source = self.get_source(sourceent.type, sourceent.name,
   331                                      sourceent.host_config, sourceent.eid)
   328                                      sourceent.host_config, sourceent.eid)
   332         except RuntimeError:
   329         except RuntimeError:
   342             # internal session, which is not possible until connections sets have been
   339             # internal session, which is not possible until connections sets have been
   343             # initialized)
   340             # initialized)
   344             source.init(True, sourceent)
   341             source.init(True, sourceent)
   345         else:
   342         else:
   346             source.init(False, sourceent)
   343             source.init(False, sourceent)
   347         self._clear_planning_caches()
   344         self._clear_source_defs_caches()
   348 
   345 
   349     def remove_source(self, uri):
   346     def remove_source(self, uri):
   350         source = self.sources_by_uri.pop(uri)
   347         source = self.sources_by_uri.pop(uri)
   351         del self.sources_by_eid[source.eid]
   348         del self.sources_by_eid[source.eid]
   352         self._clear_planning_caches()
   349         self._clear_source_defs_caches()
   353 
   350 
   354     def get_source(self, type, uri, source_config, eid=None):
   351     def get_source(self, type, uri, source_config, eid=None):
   355         # set uri and type in source config so it's available through
   352         # set uri and type in source config so it's available through
   356         # source_defs()
   353         # source_defs()
   357         source_config['uri'] = uri
   354         source_config['uri'] = uri
   587         sources = {}
   584         sources = {}
   588         # remove sensitive information
   585         # remove sensitive information
   589         for uri, source in self.sources_by_uri.items():
   586         for uri, source in self.sources_by_uri.items():
   590             sources[uri] = source.public_config
   587             sources[uri] = source.public_config
   591         return sources
   588         return sources
       
   589 
       
   590     def _clear_source_defs_caches(self):
       
   591         clear_cache(self, 'source_defs')
   592 
   592 
   593     def properties(self):
   593     def properties(self):
   594         """Return a result set containing system wide properties.
   594         """Return a result set containing system wide properties.
   595 
   595 
   596         This is a public method, not requiring a session id.
   596         This is a public method, not requiring a session id.