Guido van Rossum | 6c15046 | 1995-04-28 22:28:39 +0000 | [diff] [blame^] | 1 | Filesystem, RCS and CVS client and server classes |
| 2 | ================================================= |
| 3 | |
Guido van Rossum | 5f07b84 | 1995-04-26 22:57:11 +0000 | [diff] [blame] | 4 | This directory contains various modules and classes that support |
Guido van Rossum | 6c15046 | 1995-04-28 22:28:39 +0000 | [diff] [blame^] | 5 | remote file system operations. |
| 6 | |
| 7 | rrcs.py Remote RCS client command line interface |
| 8 | rrcs Script to put in your bin directory |
| 9 | |
| 10 | rcvs.py Remote CVS client command line interface |
| 11 | rcvs Script to put in your bin directory |
| 12 | |
| 13 | sumtree.py Old demo for FSProxy |
| 14 | cmptree.py First FSProxy client (used to sync from the Mac) |
| 15 | |
| 16 | cvslib.py CVS admin files classes (used by rrcs) |
| 17 | rcsclient.py Return an RCSProxyClient instance |
| 18 | (has reasonable default server/port/directory) |
| 19 | |
| 20 | FSProxy.py Filesystem interface classes |
| 21 | RCSProxy.py RCS interface classes |
| 22 | |
| 23 | client.py Client class |
| 24 | server.py Server class |
| 25 | |
| 26 | cmdfw.py CommandFrameWork class |
| 27 | (used by rcvs, should be used by rrcs as well) |
| 28 | |
| 29 | |
| 30 | Client/Server operation |
| 31 | ----------------------- |
| 32 | |
| 33 | The Client and Server classes implement a simple-minded RPC protocol, |
| 34 | using Python's pickle module to transfer arguments, return values and |
| 35 | exceptions with the most generality. The Server class is instantiated |
| 36 | with a port number on which it should listen for requests; the Client |
| 37 | class is instantiated with a host name and a port number where it |
| 38 | should connect to. Once a client is connected, a TCP connection is |
| 39 | maintained between client and server. |
| 40 | |
| 41 | The Server class currently handles only one connection at a time; |
| 42 | however it could be rewritten to allow various modes of operations, |
| 43 | using multiple threads or processes or the select() system call as |
| 44 | desired to serve multiple clients simultaneously (when using select(), |
| 45 | still handling one request at a time). This would not require |
| 46 | rewriting of the Client class. It may also be possible to adapt the |
| 47 | code to use UDP instead of TCP, but then both classes will have to be |
| 48 | rewritten (and unless extensive acknowlegements and request serial |
| 49 | numbers are used, the server should handle duplicate requests, so its |
| 50 | semantics should be idempotent -- shrudder). |
| 51 | |
| 52 | Even though the FSProxy and RCSProxy modules define client classes, |
| 53 | the client class is fully generic -- what methods it supports is |
| 54 | determined entirely by the server. The server class, however, must be |
| 55 | derived from. This is generally done as follows: |
| 56 | |
| 57 | from server import Server |
| 58 | from client import Client |
| 59 | |
| 60 | # Define a class that performs the operations locally |
| 61 | class MyClassLocal: |
| 62 | def __init__(self): ... |
| 63 | def _close(self): ... |
| 64 | |
| 65 | # Derive a server class using multiple inheritance |
| 66 | class MyClassServer(MyClassLocal, Server): |
| 67 | def __init__(self, address): |
| 68 | # Must initialize MyClassLocal as well as Server |
| 69 | MyClassLocal.__init__(self) |
| 70 | Server.__init__(self, address) |
| 71 | def _close(self): |
| 72 | Server._close() |
| 73 | MyClassLocal._close() |
| 74 | |
| 75 | # A dummy client class |
| 76 | class MyClassClient(Client): pass |
| 77 | |
| 78 | Note that because MyClassLocal isn't used in the definition of |
| 79 | MyClassClient, it would actually be better to place it in a separate |
| 80 | module so the definition of MyClassLocal isn't executed when we only |
| 81 | instantiate a client. |
| 82 | |
| 83 | The modules client and server should probably be renamed to Client and |
| 84 | Server in order to match the class names. |