From 84375e9cf52e9713ff1b509ca199fdbedfec29bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 9 Feb 2018 15:04:00 +0100 Subject: [PATCH] Improve attachment of always necessary data to response in webide --- src/event_handlers/source_code_event_handler.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/event_handlers/source_code_event_handler.py b/src/event_handlers/source_code_event_handler.py index eb64c1d..6dd33d7 100644 --- a/src/event_handlers/source_code_event_handler.py +++ b/src/event_handlers/source_code_event_handler.py @@ -59,15 +59,11 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin): def read(self, data): try: data['content'] = self.filemanager.file_contents except PermissionError: data['content'] = 'You have no permission to open that file :(' - data['filename'] = self.filemanager.filename - data['language'] = self.filemanager.language - data['files'] = self.filemanager.files return data def write(self, data): try: self.filemanager.file_contents = data['content'] except Exception: log.exception('Error writing file!') - data['files'] = self.filemanager.files self.restart_process() return data @@ -76,9 +72,15 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin): except EnvironmentError: log.exception('Failed to select file "{}"'.format(data['filename'])) return data + def attach_fileinfo(self, data): + data['filename'] = self.filemanager.filename + data['language'] = self.filemanager.language + data['files'] = self.filemanager.files + def handle_event(self, anchor, data_json): data = data_json['data'] data_json['data'] = self.commands[data['command']](data) + self.attach_fileinfo(data) return data_json