From 90d8e0399c02c3e2b63ff1d719bf02a874985422 Mon Sep 17 00:00:00 2001
From: Luke Leighton <lkcl@lkcl.net>
Date: Sun, 12 Sep 2010 13:23:56 +0100
Subject: [PATCH 09/34] move JSONRPC service to separate module

---
 gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py  |   17 +----------------
 gnumed/gnumed/client/ProxiedWeb/gui/LoginPanel.py |    6 +++---
 gnumed/gnumed/client/ProxiedWeb/gui/Remote.py     |   19 +++++++++++++++++++
 3 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 gnumed/gnumed/client/ProxiedWeb/gui/Remote.py

diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py b/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py
index 7eb46cd..34df89c 100644
--- a/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/GNUmedWeb.py
@@ -3,9 +3,6 @@ import pyjd # dummy in pyjs
 from pyjamas.ui.RootPanel import RootPanel
 from pyjamas.ui.DockPanel import DockPanel
 from pyjamas.ui import HasAlignment
-from pyjamas.JSONService import JSONProxy
-
-import jsonobjproxy # just to get it in for pyjs
 
 from LoginPanel import cLoginPanel
 from MainPanel import cMainPanel
@@ -21,8 +18,7 @@ class gmTopLevelLayer:
         GMWevents.events.addLoginListener(self) # want to receive onLogin
 
         self.TEXT_ERROR = "Server Error"
-        self.remote_py = EchoServicePython()
-        self.loginpanel = cLoginPanel(self) # fires logged out on UI load
+        self.loginpanel = cLoginPanel() # fires logged out on UI load
         self.afterloginpanel = cMainPanel(self, Spacing=8, Width="100%")
 
         self.maindisplay = DockPanel(HorizontalAlignment=HasAlignment.ALIGN_CENTER,
@@ -50,17 +46,6 @@ class gmTopLevelLayer:
         self.maindisplay.add(self.afterloginpanel, DockPanel.CENTER)
 
 #======================================================
-class EchoServicePython(JSONProxy):
-    def __init__(self):
-        JSONProxy.__init__(self, "/JSON",
-                ["login",
-                "echo", "get_doc_types",
-                "get_schema_version",
-                "get_documents",
-                "doSomething",
-                "search_patient"])
-
-#======================================================
 if __name__ == '__main__':
     # for pyjd, set up a web server and load the HTML from there:
     # this convinces the browser engine that the AJAX will be loaded
diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/LoginPanel.py b/gnumed/gnumed/client/ProxiedWeb/gui/LoginPanel.py
index d92317f..1deedb6 100644
--- a/gnumed/gnumed/client/ProxiedWeb/gui/LoginPanel.py
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/LoginPanel.py
@@ -1,10 +1,10 @@
 from pyjamas.builder.Builder import Builder, HTTPUILoader
 import GMWevents
+import Remote
 
 #======================================================
 class cLoginPanel: 
-    def __init__(self, app):
-        self.app = app
+    def __init__(self):
         self.lp = None
         self.TEXT_WAITING = "Waiting for response..."
         HTTPUILoader(self).load("gnumedweb.xml") # calls onUILoaded when done
@@ -29,7 +29,7 @@ class cLoginPanel:
         self.try_user = self.lp.CaptionPanel1.Grid1.username.getText()
         passwd = self.lp.CaptionPanel1.Grid1.password.getText() 
         self.lp.CaptionPanel1.Grid1.password.setText("") # reset to blank
-        self.app.remote_py.login(self.try_user, passwd, self)
+        Remote.svc.login(self.try_user, passwd, self)
 
     #--------------------------------------------------
     def onRemoteResponse(self, response, request_info):
diff --git a/gnumed/gnumed/client/ProxiedWeb/gui/Remote.py b/gnumed/gnumed/client/ProxiedWeb/gui/Remote.py
new file mode 100644
index 0000000..1fe5b78
--- /dev/null
+++ b/gnumed/gnumed/client/ProxiedWeb/gui/Remote.py
@@ -0,0 +1,19 @@
+from pyjamas.JSONService import JSONProxy
+
+import jsonobjproxy # just to get it in for pyjs compiler
+
+#======================================================
+class EchoServicePython(JSONProxy):
+    def __init__(self):
+        JSONProxy.__init__(self, "/JSON",
+                ["login",
+                "echo", "get_doc_types",
+                "get_schema_version",
+                "get_documents",
+                "doSomething",
+                "search_patient"])
+
+#======================================================
+
+svc = EchoServicePython()
+
-- 
1.7.1

