Use initial version of SourceCodeEventHandler

This commit is contained in:
Bálint Bokros 2018-01-10 16:49:23 +01:00
parent 1d1cab228b
commit 0b8542fc39
2 changed files with 17 additions and 7 deletions

View File

@ -4,3 +4,11 @@ import json
def parse_anchor_from_message(message):
message_json = json.loads(message)
return message_json['anchor']
def create_source_code_response_data(filename, content, language):
return {
'filename': filename,
'content': content,
'language': language
}

View File

@ -1,12 +1,19 @@
import codecs
import sqlite3
from functools import partial
import source_code
from event_handler import EventHandler
from source_code_event_handler import SourceCodeEventHandler
from stateful_event_handler import StatefulEventHandler
from tornado.ioloop import IOLoop
from login_component import authorize_login
from util import create_source_code_response_data
login_component_py_response = partial(
create_source_code_response_data, filename='login_component.py', language='python'
)
def echo_handler(data):
@ -38,7 +45,7 @@ def login_handler(data):
)
yield ('anchor_webide',
source_code.get_source_code(authorize_login, strip_comments=False))
login_component_py_response(content=source_code.get_source_code(authorize_login, strip_comments=False)))
sql_statement_with_values = sql_statement.format(email, password)
yield (
@ -70,16 +77,11 @@ def login_handler(data):
yield ('anchor_login', '# Login page\n' + response)
def source_code_handler(data):
yield (data['anchor'],
source_code.get_source_code(authorize_login, strip_comments=True))
if __name__ == '__main__':
anchor_a = EventHandler('anchor_a', change_case_handler)
anchor_b = EventHandler('anchor_b', rot13_handler)
anchor_c = EventHandler('anchor_c', reverse_handler)
anchor_login = StatefulEventHandler('anchor_login', login_handler)
anchor_webide = StatefulEventHandler('anchor_webide', source_code_handler)
anchor_webide = SourceCodeEventHandler('anchor_webide', 'login_component.py', 'login')
IOLoop.instance().start()