From ed2e2aa338e29e70ee15b5b731f83d2582f06b6b Mon Sep 17 00:00:00 2001 From: Pedro Ferreira Date: Tue, 6 Sep 2011 14:15:05 +0200 Subject: [PATCH] [FIX] Problem loading livesync * Added auto DB-update when data structure does not exist; --- indico/ext/livesync/agent.py | 8 +++++++- indico/ext/livesync/db.py | 14 +++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/indico/ext/livesync/agent.py b/indico/ext/livesync/agent.py index fb8a28e15..f8e0403a7 100644 --- a/indico/ext/livesync/agent.py +++ b/indico/ext/livesync/agent.py @@ -37,9 +37,11 @@ from indico.ext.livesync.struct import SetMultiPointerTrack from indico.ext.livesync.util import getPluginType from indico.ext.livesync.struct import EmptyTrackException from indico.ext.livesync.base import ILiveSyncAgentProvider, MPT_GRANULARITY +from indico.ext.livesync.db import updateDBStructures # legacy indico imports from MaKaC import conference +from MaKaC.common import DBMgr class QueryException(Exception): """ @@ -297,7 +299,11 @@ class SyncManager(Persistent): Returns the instance of SyncManager currently in the DB """ storage = getPluginType().getStorage() - return storage['agent_manager'] + if 'agent_manager' in storage: + return storage['agent_manager'] + else: + root = DBMgr.getInstance().getDBConnection() + updateDBStructures(root) def reset(self, agentsOnly=False, trackOnly=False): """ diff --git a/indico/ext/livesync/db.py b/indico/ext/livesync/db.py index 3edd015a0..eb5466e58 100644 --- a/indico/ext/livesync/db.py +++ b/indico/ext/livesync/db.py @@ -25,10 +25,8 @@ This should be easy to adapt to InTRePId 2, in the case of its acceptance. """ # plugin imports -from indico.ext.livesync.util import getPluginType -from indico.ext.livesync.agent import SyncManager + from indico.ext.livesync.base import MPT_GRANULARITY -from indico.core.extpoint.db import DBUpdateException def updateDBStructures(root, granularity=MPT_GRANULARITY): @@ -36,15 +34,17 @@ def updateDBStructures(root, granularity=MPT_GRANULARITY): Updates the DB for use with livesync """ + from indico.ext.livesync.util import getPluginType + from indico.ext.livesync.agent import SyncManager + # get our storage ptype = getPluginType() storage = ptype.getStorage() # check if it is empty - if len(storage) == 0: + if 'agent_manager' in storage: + raise Exception("This DB seems to already have livesync installed") + else: # nice, let's fill it storage['agent_manager'] = SyncManager(granularity=granularity) return True - - else: - raise Exception("This DB seems to already have livesync installed") -- 2.11.4.GIT