mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:41:33 +00:00
Improve attachment of always necessary data to response in webide
This commit is contained in:
parent
87b1163060
commit
84375e9cf5
@ -59,15 +59,11 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
def read(self, data):
|
def read(self, data):
|
||||||
try: data['content'] = self.filemanager.file_contents
|
try: data['content'] = self.filemanager.file_contents
|
||||||
except PermissionError: data['content'] = 'You have no permission to open that file :('
|
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
|
return data
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
try: self.filemanager.file_contents = data['content']
|
try: self.filemanager.file_contents = data['content']
|
||||||
except Exception: log.exception('Error writing file!')
|
except Exception: log.exception('Error writing file!')
|
||||||
data['files'] = self.filemanager.files
|
|
||||||
self.restart_process()
|
self.restart_process()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -76,9 +72,15 @@ class SourceCodeEventHandler(EventHandlerBase, SupervisorMixin):
|
|||||||
except EnvironmentError: log.exception('Failed to select file "{}"'.format(data['filename']))
|
except EnvironmentError: log.exception('Failed to select file "{}"'.format(data['filename']))
|
||||||
return data
|
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):
|
def handle_event(self, anchor, data_json):
|
||||||
data = data_json['data']
|
data = data_json['data']
|
||||||
data_json['data'] = self.commands[data['command']](data)
|
data_json['data'] = self.commands[data['command']](data)
|
||||||
|
self.attach_fileinfo(data)
|
||||||
return data_json
|
return data_json
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user