Skip to content

Commit 717aa23

Browse files
committed
Working implementation. To be refined. To be added body events to the App.
1 parent fed8376 commit 717aa23

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

remi/gui.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,18 +1037,15 @@ def onload(self):
10371037
return ()
10381038

10391039
@decorate_set_on_listener("(self, emitter)")
1040-
@decorate_event_js("""
1041-
function(message, source, lineno, colno, error){
1042-
var params={};params['message']=message;
1043-
params['source']=source;
1044-
params['lineno']=lineno;
1045-
params['colno']=colno;
1040+
@decorate_event_js("""var params={};params['message']=event.message;
1041+
params['source']=event.source;
1042+
params['lineno']=event.lineno;
1043+
params['colno']=event.colno;
10461044
sendCallbackParam('%(emitter_identifier)s','%(event_name)s',params);
10471045
return false;
1048-
}""")
1046+
""")
10491047
def onerror(self, message, source, lineno, colno):
10501048
"""Called when an error occurs."""
1051-
print("DOCUMENT ERROR: " + message)
10521049
return (message, source, lineno, colno)
10531050

10541051
@decorate_set_on_listener("(self, emitter)")

remi/server.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,14 @@ def _instance(self):
623623

624624
self.client = clients[self.session]
625625

626+
if not hasattr(self.client, 'page'):
627+
head = gui.HEAD(self.server.title, self.client.js_head + '\n' + self.client.js_body_end, self.client.css_head, self.client.html_head)
628+
body = gui.BODY()
629+
body.disable_refresh()
630+
self.client.page = gui.HTML()
631+
self.client.page.add_child('head', head)
632+
self.client.page.add_child('body', body)
633+
626634
if not hasattr(clients[self.session], 'websockets'):
627635
clients[self.session].websockets = []
628636

@@ -689,6 +697,7 @@ def websocket_handshake_done(self, ws_instance_to_update):
689697
ws_instance_to_update.send_message(msg)
690698

691699
def set_root_widget(self, widget):
700+
self.page.children['body'].append(widget, 'root')
692701
self.root = widget
693702
self.root.disable_refresh()
694703
self.root.attributes['data-parent-widget'] = str(id(self))
@@ -819,7 +828,7 @@ def do_GET(self):
819828
# build the page (call main()) in user code, if not built yet
820829
with self.update_lock:
821830
# build the root page once if necessary
822-
if not hasattr(self.client, 'root') or self.client.root is None:
831+
if not 'root' in self.client.page.children['body'].children.keys():
823832
self._log.info('built UI (path=%s)' % path)
824833
self.client.set_root_widget(self.main(*self.server.userdata))
825834
self._process_all(path)
@@ -846,14 +855,6 @@ def _process_all(self, func):
846855
self.send_header('Content-type', 'text/html')
847856
self.end_headers()
848857

849-
#WARNING !!! MUTUAL/CIRCUAL import???
850-
self.client.head = gui.HEAD(self.server.title, self.client.js_head + '\n' + self.client.js_body_end, self.client.css_head, self.client.html_head)
851-
self.client.body = gui.BODY()
852-
self.client.body.append(self.client.root)
853-
self.client.page = gui.HTML()
854-
self.client.page.add_child('head', self.client.head)
855-
self.client.page.add_child('body', self.client.body)
856-
857858
with self.update_lock:
858859
# render the HTML
859860
page_content = self.client.page.repr()

0 commit comments

Comments
 (0)