[Zope-dev] Using Zope in a client-server system

Itai Tavor itavor@bigpond.net.au
Sun, 5 Mar 2000 15:50:09 +1100


Tres Seaver wrote:

>>  Michel Pelletier wrote:
>>
>>  >  Itai Tavor wrote:
>>  <snip>
>>  >
>>  >>  There are a couple of features that I am not sure how to 
>>implement though:
>>  >>
>>  >>  - I need to display constantly-updating information on the
>>  >>  workstations. I could do this by reloading the window every second,
>>  >>  but that seems ugly - I'd like to only update certain fields, which I
>>  >>  can do using layers and JavaScript, but I need to get the updated
>>  >>  data from the server. I guess that can be done with Java, but I'd
>>  >>  like to keep the system simple - a browser with HTML and JavaScript
>>  >>  only on the client side, DTML, Zope with Python Methods, and External
>>  >>  Methods, and an SQL database on the server, no Java or any other
>>  >>  complications.
>>  >
>>  >  Ah, well, you see you've hit one of the disadvantages of using a
>>  >  stateless protocol like HTTP to solve your problem.  There is no good
>>  >  general purpose solution that I know of to address this issue.
>>
>>  HTTP not being bi-directional is a bigger problem than it being
>>  stateless... I planned to use a session product that will identify
>>  each workstation and keep a record of exactly what is happening on
>>  it. But the biggest problem is that the browser / web server setup is
>>  client event driven.
>>
>>  >>  - I also need to push data to the workstations - based on events
>>  >>  detected at the server, I need to bring up a message on a
>>  >>  workstation, and remove it in response to another event. I really
>>  >>  don't want to refresh a frame every second for this, and I also would
>>  >>  hate to have to write a Java applet to do it.
>>  >
>>  >  This is the identical problem to the one above.
>>  >
>>  >>  Any comments or suggestions regarding the above problems, the choice
>>  >>  of Zope for this project, or the project in general would be
>>  >>  appreciated.
>>  >
>>  >  If you want to go far enough, you can try and use XML-RPC (also,
>>  >  stateless, but not client-bound to a certain model) and something like
>>  >  wxPython to build your own GUI that can at least mantain some sort of
>>  >  persistent or bi-directional communication between your clients and
>>  >  servers.  But this is a big task.
>>
>>  Programming my own GUI is already farther than I'd like to go... and
>>  if I do, would it still be a good idea to use Zope on the server
>>  side? If I use Zope, wouldn't I still have to use HTTP? How otherwise
>>  can I get the client to communicate with the server? (Complete
>>  ignorance of XML-RPC implied here.)
>>
>>  >  I think if you maybe rethink your problem you can compromise on
>>  >  something that does not require the server pushing data to the client.
>>
>>  Yeah, without actually failing to deliver any of the features the
>>  client is expecting... the only way I can think of is simply to
>>  reload certain frames every second... seems like a very ugly solution.
>>
>>  I need to quote on time and cost for this project, and to do that I
>>  have to figure out the tools I'd be using. I'm sure a Zope/web
>>  browser solution will be the quickest, but if I go that way and get
>>  stuck, I won't be in a very enviable position. I'm sure that most
>>  programmers would immediately start coding Java or VB at this
>>  point... am I making a mistake trying to apply Zope to a task it's
>>  not good for?
>
>  By default, browsers aren't servers:  they don't know from
>  bind()/listen()/accept(), which is what push technology requires (unless you
>  have a long-running, bi-directional connection between browser and 
>server, which
>  HTTP doesn't allow).  Polling is the only "native" technique for refresh, and
>  suffers from _horrible_ scalability problems.
>
>  Options in order of simplicity:
>
>   1. Pull instead of push (ick!)

My sentiments exactly.

>   2. As Hung Jung suggests, build the "push model" stuff separately from the
>      browser, using Python or Java to implement HTTP (and perhaps XML-RPC?)
>      Integration with the browser is difficult:  clients will have to have
>      some mechanism for registering their mini-server with your server;
>      if you want the broser's display to update when the push event comes in,
>      you may be stuck.

Right. Mixing two GUI's - a browser for most of the interface and a 
separate app for pushed data - would be real ugly. So I either have 
to work inside the browser, as in option 3 below, or code my own GUI.

Registering the mini-servers would not be a problem. This project 
will be running on a small number of workstations, all located in one 
location. It's not designed for public or wide-area use and won't 
even be connected to the internet.

So, the problem with this solution is how to get the pushed data into the GUI.

>   3. Code a lightweight socket server applet in Java, persuade everyone in
>      the world to trust you to run it in their "applet sandbox", and then
>      "register" it with your server.

Again, because of the physical layout of the project, trust won't be 
an issue, which makes this solution rather attractive.

>   4. Write a CORBA callback object in Java, and register it with your server;
>      the server then pushes events to your object (scalability is again an
>      issue, as the server blocks for each client being pushed).  Note that
>      adding CORBA into Zope is a non-trivial exercise, for the 
>moment at least;
>      see my "notes":http://www.zope.org/Members/tseaver/CosNaming on the
>      issues.

I read your notes, and I think I'd like to stay away from COBRA - I'd 
use it if I decided to go totally overboard and code both the server 
and client in Java. But with Zope on the server end, XML-RPC seems 
like the best way to communicate.

>   5. Write a CORBA event-channel applet (CosEventPushConsumer) in Java, set
>      up a CosEvent/CosNotification channel, subscribe the applet to it, and
>      push events to the channel from your server (decouples your server from
>      event-delivery hassles/blockage, scales MUCH better than direct 
>callbacks).

Scalability is not much of a problem for me. I wouldn't like the 
server to block too much but that shouldn't be much of a problem 
either - with 10 clients on a 100baseT network, and 4 Zope threads on 
a fast server, I can't imagine running into any performance problems. 
But I do want to keep the number of technologies and separate apps 
involved to a minimum, and this seems fairly complicated.


Out of the various options suggested it seems to me that the main 
options to consider are:

- Use a browser for the main GUI, and either compromise the 
requirements to eliminate the need for push or code an applet to 
display push data in the browser.

- Write my own GUI.

The second option raises some new questions:

- Would it still be a good idea to use Zope for the server, or should 
I code the server as well (a full Java solution comes to mind using 
COBRA for two-way communication). How would I handle push in Zope? 
Assuming I code a push client that speaks XML-RPC, how do I get Zope 
to send data outside the context of an http transaction? Actually, 
this same question is relevant for the solution of using a Java 
applet within the browser.

- Two good candidates for writing the GUI in are Java and wxPython. 
Using wxPython would have the advantage of keeping everything in 
Python. On the other hand, there's an XML-RPC server for Java, but 
not for Python - I guess I would use HTTP if I use wxPython. Can 
anyone suggest pros/cons for these solutions?


I have one other question related to the use of Zope in this project: 
The server has to monitor a serial line and respond to received data 
by pushing messages to the clients. What would be the best way to 
achieve this? An external python process reading the serial line and 
calling ZPublisher.Client to triger a DTML method that will do the 
rest of the work?


P.S. I know this is getting way off topic for the Zope group. I 
really appreciate all of you contributing your experience.

Itai
--
Itai Tavor                      -- "Je sautille, donc je suis."    --
itavor@vic.bigpond.net.au       --               - Kermit the Frog --
-- "What he needs now is understanding... and a confederate victory" --
-- Dr. Jacobi, Twin Peaks         --