Add create_backend helper method to agent model

This commit is contained in:
Adrian Moennich 2014-11-11 17:04:19 +01:00
parent a18593ec84
commit c2984bdd7d
2 changed files with 6 additions and 2 deletions

View File

@ -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()

View File

@ -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 '<LiveSyncAgent({}, {}, {})>'.format(self.id, self.backend_name, self.name)