Commit cb43e492 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[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).

--HG--
branch : 3.25
parent 232eefd6d3b3
......@@ -350,10 +350,7 @@ class Repository(object):
# 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 @@ class Repository(object):
' 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
......
......@@ -186,12 +186,10 @@ class AbstractSource(object):
"""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()
......
......@@ -107,8 +107,8 @@ class DataFeedSource(AbstractSource):
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
......
......@@ -176,8 +176,8 @@ You can set multiple groups by separating them by a comma.',
_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')})
......
......@@ -427,8 +427,8 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment