diff --git a/livesync/indico_livesync/cli.py b/livesync/indico_livesync/cli.py index 37fef3e..e701538 100644 --- a/livesync/indico_livesync/cli.py +++ b/livesync/indico_livesync/cli.py @@ -83,7 +83,7 @@ def initial_export(agent_id, force=False): transaction.abort() with DBMgr.getInstance().global_connection(): - agent.backend(agent).run_initial_export(_iter_events()) + agent.create_backend().run_initial_export(_iter_events()) agent.initial_data_exported = True db.session.commit() @@ -128,6 +128,6 @@ def run(agent_id=None): print cformat('Running agent: %{white!}{}%{reset}').format(agent.name) with DBMgr.getInstance().global_connection(): try: - agent.backend(agent).run() + agent.create_backend().run() finally: transaction.abort() diff --git a/livesync/indico_livesync/models/agents.py b/livesync/indico_livesync/models/agents.py index fcb0f55..b8a16e6 100644 --- a/livesync/indico_livesync/models/agents.py +++ b/livesync/indico_livesync/models/agents.py @@ -64,6 +64,10 @@ class LiveSyncAgent(db.Model): from indico_livesync.plugin import LiveSyncPlugin return LiveSyncPlugin.instance.agent_classes.get(self.backend_name) + def create_backend(self): + """Creates a new backend instance""" + return self.backend(self) + @return_ascii def __repr__(self): return ''.format(self.id, self.backend_name, self.name)