# HG changeset patch # User Sylvain Thénault # Date 1492004945 -7200 # Node ID 79160d54662ebf49a5acd3080f1b6f7ddeed29fa # Parent 232eefd6d3b3dc5fef549236f48f2aa8172b9dad [sources] Simplify source's init method Only call it when enabled instead of giving a boolean flag indicating whether it is or not (which were not correctly considered). diff -r 232eefd6d3b3 -r 79160d54662e cubicweb/server/repository.py --- a/cubicweb/server/repository.py Wed Apr 12 14:54:10 2017 +0200 +++ b/cubicweb/server/repository.py Wed Apr 12 15:49:05 2017 +0200 @@ -350,10 +350,7 @@ # needed (for instance looking for persistent configuration using an # internal session, which is not possible until connections sets have been # initialized) - source.init(True, sourceent) - else: - source.init(False, sourceent) - source.set_schema(self.schema) + source.init(sourceent) return source # internals ############################################################### @@ -368,7 +365,7 @@ ' S name "system", S type SA, S config SC' ).one() self.system_source.eid = sourceent.eid - self.system_source.init(True, sourceent) + self.system_source.init(sourceent) def get_source(self, type, uri, source_config, eid=None): # set uri and type in source config so it's available through diff -r 232eefd6d3b3 -r 79160d54662e cubicweb/server/sources/__init__.py --- a/cubicweb/server/sources/__init__.py Wed Apr 12 14:54:10 2017 +0200 +++ b/cubicweb/server/sources/__init__.py Wed Apr 12 15:49:05 2017 +0200 @@ -186,12 +186,10 @@ """method called by the repository once ready to create a new instance""" pass - def init(self, activated, source_entity): + def init(self, source_entity): """method called by the repository once ready to handle request. `activated` is a boolean flag telling if the source is activated or not. """ - if not activated: - return source_entity.complete() if source_entity.url: self.urls = [url.strip() for url in source_entity.url.splitlines() diff -r 232eefd6d3b3 -r 79160d54662e cubicweb/server/sources/datafeed.py --- a/cubicweb/server/sources/datafeed.py Wed Apr 12 14:54:10 2017 +0200 +++ b/cubicweb/server/sources/datafeed.py Wed Apr 12 15:49:05 2017 +0200 @@ -107,8 +107,8 @@ raise ValidationError(source_entity.eid, {'config': msg}) return typed_config - def init(self, activated, source_entity): - super(DataFeedSource, self).init(activated, source_entity) + def init(self, source_entity): + super(DataFeedSource, self).init(source_entity) self.parser_id = source_entity.parser self.latest_retrieval = source_entity.latest_retrieval typed_config = self.config diff -r 232eefd6d3b3 -r 79160d54662e cubicweb/server/sources/ldapfeed.py --- a/cubicweb/server/sources/ldapfeed.py Wed Apr 12 14:54:10 2017 +0200 +++ b/cubicweb/server/sources/ldapfeed.py Wed Apr 12 15:49:05 2017 +0200 @@ -176,8 +176,8 @@ _conn = None - def init(self, activated, source_entity): - super(LDAPFeedSource, self).init(activated, source_entity) + def init(self, source_entity): + super(LDAPFeedSource, self).init(source_entity) if self.urls: if len(self.urls) > 1: raise ValidationError(source_entity.eid, {'url': _('can only have one url')}) diff -r 232eefd6d3b3 -r 79160d54662e cubicweb/server/sources/native.py --- a/cubicweb/server/sources/native.py Wed Apr 12 14:54:10 2017 +0200 +++ b/cubicweb/server/sources/native.py Wed Apr 12 15:49:05 2017 +0200 @@ -427,8 +427,8 @@ else: raise ValueError('Unknown format %r' % format) - def init(self, activated, source_entity): - super(NativeSQLSource, self).init(activated, source_entity) + def init(self, source_entity): + super(NativeSQLSource, self).init(source_entity) self.init_creating(source_entity._cw.cnxset) def shutdown(self):