diff --git a/app/events.py b/app/events.py index 31484705..96f6de26 100644 --- a/app/events.py +++ b/app/events.py @@ -59,13 +59,12 @@ def user_ressource_session_handler(app, user_id, session_id, foreign=False): ' NOTE: The initial values are send as a init events. ' The JSON patches are send as update events. ''' - init_events = {'corpora': 'foreign_corpora_init' if foreign - else 'corpora_init', - 'jobs': 'foreign_jobs_init' if foreign else 'jobs_init'} - update_events = {'corpora': 'foreign_corpora_update' if foreign - else 'corpora_update', - 'jobs': 'foreign_jobs_update' if foreign - else 'jobs_update'} + init_events = \ + {'corpora': 'foreign_corpora_init' if foreign else 'corpora_init', + 'jobs': 'foreign_jobs_init' if foreign else 'jobs_init'} + update_events = \ + {'corpora': 'foreign_corpora_update' if foreign else 'corpora_update', + 'jobs': 'foreign_jobs_update' if foreign else 'jobs_update'} with app.app_context(): # Gather current values from database. user = User.query.get(user_id) @@ -77,7 +76,8 @@ def user_ressource_session_handler(app, user_id, session_id, foreign=False): socketio.emit(init_events['jobs'], json.dumps(jobs), room=session_id) while session_id in connected_sessions: # Get new values from the database - new_corpora = {corpus.id: corpus.to_dict() for corpus in user.corpora} + new_corpora = {corpus.id: corpus.to_dict() + for corpus in user.corpora} new_jobs = {job.id: job.to_dict() for job in user.jobs} # Compute JSON patches. corpora_patch = jsonpatch.JsonPatch.from_diff(corpora, new_corpora)